All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	syzbot+e87ebe0f7913f71f2ea5@syzkaller.appspotmail.com,
	stable <stable@vger.kernel.org>
Subject: [PATCH] USB: yurex: fix control-URB timeout handling
Date: Mon, 14 Dec 2020 11:44:44 +0100	[thread overview]
Message-ID: <20201214104444.28386-1-johan@kernel.org> (raw)
In-Reply-To: <000000000000e2186705b65e671f@google.com>

Make sure to always cancel the control URB in write() so that it can be
reused after a timeout or spurious CMD_ACK.

Currently any further write requests after a timeout would fail after
triggering a WARN() in usb_submit_urb() when attempting to submit the
already active URB.

Reported-by: syzbot+e87ebe0f7913f71f2ea5@syzkaller.appspotmail.com
Fixes: 6bc235a2e24a ("USB: add driver for Meywa-Denki & Kayac YUREX")
Cc: stable <stable@vger.kernel.org>     # 2.6.37
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/misc/yurex.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/misc/yurex.c b/drivers/usb/misc/yurex.c
index 73ebfa6e9715..c640f98d20c5 100644
--- a/drivers/usb/misc/yurex.c
+++ b/drivers/usb/misc/yurex.c
@@ -496,6 +496,9 @@ static ssize_t yurex_write(struct file *file, const char __user *user_buffer,
 		timeout = schedule_timeout(YUREX_WRITE_TIMEOUT);
 	finish_wait(&dev->waitq, &wait);
 
+	/* make sure URB is idle after timeout or (spurious) CMD_ACK */
+	usb_kill_urb(dev->cntl_urb);
+
 	mutex_unlock(&dev->io_mutex);
 
 	if (retval < 0) {
-- 
2.26.2


  reply	other threads:[~2020-12-14 10:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-12 22:33 WARNING in yurex_write/usb_submit_urb syzbot
2020-12-13 20:31 ` syzbot
2020-12-14 10:44   ` Johan Hovold [this message]
2020-12-14 10:50     ` [PATCH] USB: yurex: fix control-URB timeout handling Johan Hovold
2020-12-14 14:48       ` WARNING in yurex_write/usb_submit_urb syzbot
2020-12-14 15:02         ` Johan Hovold
2020-12-14 15:06           ` Andrey Konovalov
2020-12-14 15:16             ` Johan Hovold
2020-12-14 20:12               ` syzbot
2020-12-15 14:08               ` Andrey Konovalov
2020-12-14  4:30 ` syzbot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201214104444.28386-1-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+e87ebe0f7913f71f2ea5@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.