Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] proc: __free() variable buf declared at top of pde_ioctl_buf() --
commit 56830294f9ddc9f5679014810e7198455a39f42c Author: Christian Brauner <[email protected]> proc: let procfs copy ioctl arguments in and out This commit adds support for ->proc_ioctl_buf() and ->proc_ioctl_args in struct proc_ops so that procfs can copy ioctl arguments from and to userspace without holding the proc_dir_entry pinned across user copies. > diff --git a/fs/proc/inode.c b/fs/proc/inode.c > index caa47933c233d..717cbaad65df2 100644 > --- a/fs/proc/inode.c > +++ b/fs/proc/inode.c [ ... ] > @@ -548,11 +549,66 @@ static long pde_ioctl(struct proc_dir_entry *pde, > struct file *file, unsigned in > return -ENOTTY; > } > [ ... ] > +static long pde_ioctl_buf(struct proc_dir_entry *pde, struct file *file, > + unsigned int cmd, void __user *uarg, unsigned long > arg) > +{ > + void *buf __free(kvfree) = NULL; > + struct proc_ioctl_arg a; > + size_t size; > + long rv; > + > + if (!pde_ioctl_arg(pde, cmd, &a)) > + return -ENOTTY; > + size = max(a.in, a.out); > + if (size) { > + buf = kvzalloc(size, GFP_KERNEL); [Severity: Low] As reported by Sashiko on RFC [1], this isn't a bug, but in pde_ioctl_buf() in fs/proc/inode.c, buf is declared with __free(kvfree) = NULL at the top of the function and assigned later when size is non-zero. Since the cleanup API convention prefers defining and initializing __free() variables in a single statement rather than initializing them to NULL at the top of the function and assigning them later, could buf be defined and initialized once size is known (for example via size ? kvzalloc(size, GFP_KERNEL) : NULL)? [1] https://lore.kernel.org/r/[email protected] -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=18
