On Thu, Apr 14 2016, Lars-Peter Clausen wrote:
> Calling the ki_complete() callback will free the underlying data structure.
> Make sure that it is no longer accessed beyond that point, otherwise
> undefined behaviour might occur.
To be honest I have trouble tracking what ki_complete is. Could you
describe the path that leads to the bug in a little more detail?
> Fixes: 2e4c7553cd6f ("usb: gadget: f_fs: add aio support")
> Signed-off-by: Lars-Peter Clausen <[email protected]>
> ---
> drivers/usb/gadget/function/f_fs.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c
> b/drivers/usb/gadget/function/f_fs.c
> index e21ca2bd..15b648c 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -646,6 +646,7 @@ static void ffs_user_copy_worker(struct work_struct *work)
> work);
> int ret = io_data->req->status ? io_data->req->status :
> io_data->req->actual;
> + bool kiocb_has_eventfd = io_data->kiocb->ki_flags & IOCB_EVENTFD;
>
> if (io_data->read && ret > 0) {
> use_mm(io_data->mm);
> @@ -657,13 +658,11 @@ static void ffs_user_copy_worker(struct work_struct
> *work)
>
> io_data->kiocb->ki_complete(io_data->kiocb, ret, ret);
>
> - if (io_data->ffs->ffs_eventfd &&
> - !(io_data->kiocb->ki_flags & IOCB_EVENTFD))
> + if (io_data->ffs->ffs_eventfd && !kiocb_has_eventfd)
> eventfd_signal(io_data->ffs->ffs_eventfd, 1);
>
> usb_ep_free_request(io_data->ep, io_data->req);
>
> - io_data->kiocb->private = NULL;
> if (io_data->read)
> kfree(io_data->to_free);
> kfree(io_data->buf);
> --
> 2.1.4
>
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html