From: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
To: Alan Stern <stern@rowland.harvard.edu>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, usb-storage@lists.one-eyed-alien.net,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: [PATCH] usb-storage: onetouch: Fix potential use-after-free on input failure
Date: Wed, 11 Nov 2026 20:23:03 +0800 [thread overview]
Message-ID: <20261111-e5624093d6-usb-storage@mail.sdu.edu.cn> (raw)
If input_register_device() fails, onetouch_connect_input() frees the
onetouch state but leaves it installed in ss->extra. USB-storage cleanup
then calls onetouch_release_input() on the freed state.
Install the extra state and callbacks only after input registration
succeeds.
This issue was found by our static analysis tool under development.
Fixes: 17efe155253e ("USB: onetouch - handle errors from input_register_device()")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
---
drivers/usb/storage/onetouch.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 49d281f7bef6..e09b3c6b9a6a 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -237,16 +237,16 @@ static int onetouch_connect_input(struct us_data *ss)
onetouch->irq->transfer_dma = onetouch->data_dma;
onetouch->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
+ error = input_register_device(onetouch->dev);
+ if (error)
+ goto fail3;
+
ss->extra_destructor = onetouch_release_input;
ss->extra = onetouch;
#ifdef CONFIG_PM
ss->suspend_resume_hook = usb_onetouch_pm_hook;
#endif
- error = input_register_device(onetouch->dev);
- if (error)
- goto fail3;
-
return 0;
fail3: usb_free_urb(onetouch->irq);
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.43.0
reply other threads:[~2026-11-11 12:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261111-e5624093d6-usb-storage@mail.sdu.edu.cn \
--to=liguangshuo@mail.sdu.edu.cn \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=usb-storage@lists.one-eyed-alien.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®