[PATCH RFC 14/23] scsi: esas2r: let procfs copy the ioctl argument of the ATTONode file
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 3 07:18:54 PST 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] scsi: esas2r: split declaration and initialization of __free() variable in esas2r_ioctl_handler()
--
commit 0fd79b7040b09fc840e0499afbc88e68b34a3e18
Author: Christian Brauner <brauner at kernel.org>
scsi: esas2r: let procfs copy the ioctl argument of the ATTONode file
This commit factors the core logic of esas2r_ioctl_handler() into
esas2r_ioctl_buf() operating on a kernel copy of struct atto_express_ioctl,
and converts the procfs ATTONode file to use .proc_ioctl_buf and
.proc_ioctl_args so procfs handles copying the ioctl buffer in and out.
> diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
> index f99318f61c934..eb39ba8263b31 100644
> --- a/drivers/scsi/esas2r/esas2r_ioctl.c
> +++ b/drivers/scsi/esas2r/esas2r_ioctl.c
[ ... ]
> @@ -1515,19 +1501,43 @@ int esas2r_ioctl_handler(void *hostdata, unsigned int cmd, void __user *arg)
>
> }
>
> + return 0;
> +}
> +
> +int esas2r_ioctl_handler(void *hostdata, unsigned int cmd, void __user *arg)
> +{
> + struct atto_express_ioctl *ioctl __free(kfree) = NULL;
> + int err;
> +
> + esas2r_log(ESAS2R_LOG_DEBG, "ioctl (%p, %x, %p)", hostdata, cmd, arg);
> +
> + if ((arg == NULL)
> + || (cmd < EXPRESS_IOCTL_MIN)
> + || (cmd > EXPRESS_IOCTL_MAX))
> + return -ENOTSUPP;
> +
> + ioctl = memdup_user(arg, sizeof(struct atto_express_ioctl));
[Severity: Low]
This isn't a bug, but in esas2r_ioctl_handler() in
drivers/scsi/esas2r/esas2r_ioctl.c, ioctl is declared with __free(kfree) =
NULL at the top of the function before the argument validation check and
assigned later via memdup_user().
Per the Cleanup API conventions, could the __free(kfree) variable definition
and initialization be combined into a single statement at the point of
allocation:
struct atto_express_ioctl *ioctl __free(kfree) =
memdup_user(arg, sizeof(struct atto_express_ioctl));
after the early return check?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261102-work-procfs-drivers-v1-0-a994bd4d3b1a@kernel.org?part=14
More information about the kexec
mailing list