usb: gadget: f_fs: Fix ffs_epfile_read_iter to handle ITER_UBUF

iov_iter for ffs_epfile_read_iter can be ITER_UBUF with io_uring.
In that case dup_iter() does not have to allocate anything and it
can return NULL. ffs_epfile_read_iter treats this as a failure and
returns -ENOMEM. Fix it by checking if iter_is_ubuf().

Fixes: 1e23db450c ("io_uring: use iter_ubuf for single range imports")
Signed-off-by: Sandeep Dhavale <dhavale@google.com>
Acked-by: Jens Axboe <axboe@kernel.dk>
Link: https://lore.kernel.org/r/20230401060509.3608259-2-dhavale@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Sandeep Dhavale 2023-04-01 06:05:08 +00:00 committed by Greg Kroah-Hartman
parent eddebe3960
commit d356b3cdd0
1 changed files with 1 additions and 1 deletions

View File

@ -1251,7 +1251,7 @@ static ssize_t ffs_epfile_read_iter(struct kiocb *kiocb, struct iov_iter *to)
p->kiocb = kiocb; p->kiocb = kiocb;
if (p->aio) { if (p->aio) {
p->to_free = dup_iter(&p->data, to, GFP_KERNEL); p->to_free = dup_iter(&p->data, to, GFP_KERNEL);
if (!p->to_free) { if (!iter_is_ubuf(&p->data) && !p->to_free) {
kfree(p); kfree(p);
return -ENOMEM; return -ENOMEM;
} }