Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Low] proc: define and initialize __free(kvfree) variable buf in one 
statement in pde_read_buf()
--

commit f2c1eb05c1e48ef170c932c3f77db0e09db3d058
Author: Christian Brauner <[email protected]>

proc: let procfs copy out reads that don't go through seq_file

This commit adds a proc_read_buf callback to struct proc_ops so procfs
entries can fill a kernel buffer while pinned and let procfs copy the
buffer to userspace after unpinning the entry.

> diff --git a/fs/proc/inode.c b/fs/proc/inode.c
> index c0bb40e7ff964..3f29a1663d266 100644
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
[ ... ]
> @@ -400,11 +402,67 @@ static loff_t proc_reg_llseek(struct file *file, loff_t 
> offset, int whence)
>       return rv;
>  }
>  
> +/*
> + * The entry fills a kernel buffer and procfs copies that to userspace after
> + * unpinning the entry. A reader that faults on its buffer then doesn't hold
> + * up remove_proc_entry().
> + */
> +static ssize_t pde_read_buf(struct proc_dir_entry *pde, struct kiocb *iocb,
> +                         struct iov_iter *iter)
> +{
> +     struct file *file = iocb->ki_filp;
> +     char *buf __free(kvfree) = NULL;
> +     ssize_t rv, done = 0;
> +     size_t len, count;
> +     loff_t pos;
> +
> +     if (!iov_iter_count(iter))
> +             return 0;
> +     /* neither the allocation nor the entry can honor IOCB_NOWAIT */
> +     if ((iocb->ki_flags & IOCB_NOWAIT) && !(file->f_flags & O_NONBLOCK))
> +             return -EAGAIN;
> +     len = min_t(size_t, iov_iter_count(iter), pde->read_size);
> +     buf = kvmalloc(len, GFP_KERNEL);

[Severity: Low]
This isn't a bug, but in pde_read_buf(), buf is declared with
__free(kvfree) = NULL at the top of the function before the early return
checks for !iov_iter_count(iter) and IOCB_NOWAIT, and then assigned
separately via kvmalloc().

Could buf be defined and initialized in a single statement at the
allocation site (char *buf __free(kvfree) = kvmalloc(len, GFP_KERNEL);)
to follow the cleanup.h conventions?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=13

Reply via email to