[PATCH] usb: image: mdc800: kill download URB on timeout

Ziyi Guo posted 1 patch 3 hours ago
drivers/usb/image/mdc800.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] usb: image: mdc800: kill download URB on timeout
Posted by Ziyi Guo 3 hours ago
mdc800_device_read() submits download_urb and waits for completion.
If the timeout fires and the device has not responded, the function
returns without killing the URB, leaving it active.

A subsequent read() resubmits the same URB while it is still
in-flight, triggering the WARN in usb_submit_urb():

  "URB submitted while active"

Add usb_kill_urb() on the download timeout error path, mirroring
how the write path in the same driver already handles its URB
timeout (line 863).

Similar to
- commit 372c93131998 ("USB: yurex: fix control-URB timeout handling")
- commit b98d5000c505 ("media: rc: iguanair: handle timeouts")

Signed-off-by: Ziyi Guo <n7l8m4@u.northwestern.edu>
---
 drivers/usb/image/mdc800.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/image/mdc800.c b/drivers/usb/image/mdc800.c
index 7b7e1554ea20..c4df637b2a03 100644
--- a/drivers/usb/image/mdc800.c
+++ b/drivers/usb/image/mdc800.c
@@ -736,6 +736,7 @@ static ssize_t mdc800_device_read (struct file *file, char __user *buf, size_t l
 				mdc800->downloaded = 0;
 				if (mdc800->download_urb->status != 0)
 				{
+					usb_kill_urb(mdc800->download_urb);
 					dev_err(&mdc800->dev->dev,
 						"request download-bytes fails "
 						"(status=%i)\n",
-- 
2.34.1