From cd02d2ba933778f17cd9e7e792b9c4c76dcb0785 Mon Sep 17 00:00:00 2001 From: Mike Lockwood Date: Thu, 13 Jan 2011 16:19:57 -0500 Subject: [PATCH] USB: gadget: f_mtp: Make sure request is dequeued if transfer is canceled If the host cancels a file transfer while we have a read request pending, call usb_ep_dequeue to cancel the read. Also return -ECANCELED from mtp_ioctl if we are canceled in MTP_RECEIVE_FILE Signed-off-by: Mike Lockwood --- drivers/usb/gadget/f_mtp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/f_mtp.c b/drivers/usb/gadget/f_mtp.c index 64fe3b3cd9e6..e07224fd9f89 100644 --- a/drivers/usb/gadget/f_mtp.c +++ b/drivers/usb/gadget/f_mtp.c @@ -756,8 +756,10 @@ static void receive_file_work(struct work_struct *data) /* wait for our last read to complete */ ret = wait_event_interruptible(dev->read_wq, dev->rx_done || dev->state != STATE_BUSY); - if (ret < 0 || dev->state != STATE_BUSY) { - r = ret; + if (dev->state == STATE_CANCELED) { + r = -ECANCELED; + if (!dev->rx_done) + usb_ep_dequeue(dev->ep_out, read_req); break; } /* if xfer_file_length is 0xFFFFFFFF, then we read until -- 2.34.1