Alison Schofield wrote:
> The close() system call may modify errno. In __sysfs_read_attr(),
> errno is used after close() for both logging and the return value,
> which can result in reporting the wrong error. In write_attr(),
> errno is saved before close(), but the saved value was not used
> for logging.
> 
> Without this fix, if close() modifies errno, users may see incorrect
> error messages that don't reflect the actual failure and the function
> may return the wrong error code causing the calling code to handle
> the error incorrectly.
> 
> Save errno immediately after read() in __sysfs_read_attr(), matching
> the existing write_attr() pattern, and use the saved values for both
> logging and return paths.
> 
> Found while preparing a patch to expand the log messages in sysfs.c
> 
> Signed-off-by: Alison Schofield <[email protected]>

Reviewed-by: Ira Weiny <[email protected]>

[snip]

Reply via email to