HomeFreeBSD

mpool/mpool_get.c: Avoid clobbering 'errno' when handling 'pread' errors

Description

mpool/mpool_get.c: Avoid clobbering 'errno' when handling 'pread' errors

POSIX.1-2024 states that the 'free' function "shall not modify errno if
ptr is a null pointer or a pointer previously returned as if by malloc()
and not yet deallocated". However this is a fairly recent addition
and non-compliant allocators might still clobber 'errno', causing
'mpool_get' to return the wrong error code. Fix this by saving
and restoring 'errno' after calling 'free'.

Sponsored by: Klara, Inc.
Reviewed by: obiwac
Differential Revision: https://reviews.freebsd.org/D55463
MFC after: 1 week

Details

Provenance
bnovkovAuthored on Feb 23 2026, 3:30 PM
Reviewer
obiwac
Differential Revision
D55463: mpool/mpool_get.c: Avoid clobbering 'errno' when handling 'pread' errors
Parents
rG3023bb49e115: asmc: introduce the concept of generic models
Branches
Unknown
Tags
Unknown