mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Myeonghun Pak <mhun512@gmail.com>
To: Maxim Levitsky <maximlevitsky@gmail.com>,
	Alex Dubov <oakad@yahoo.com>, Ulf Hansson <ulfh@kernel.org>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Ijae Kim <ae878000@gmail.com>
Subject: [PATCH] memstick: rtsx_usb_ms: disable poll_card work on removal
Date: Mon,  9 Nov 2026 23:30:20 -0500	[thread overview]
Message-ID: <20261110043020.57040-1-mhun512@gmail.com> (raw)

rtsx_usb_ms_drv_remove() sets host->eject and cancels poll_card, but a
concurrent rtsx_usb_ms_set_param() that already read eject as false
can queue the work after the cancel. Its callers, memstick_check() and
ms_block error recovery, are stopped only by the later
memstick_remove_host(). The delayed work can therefore run after
memstick_free_host() frees the host.

Use disable_delayed_work_sync() to drain the work and reject later
queueing. Probe initializes fresh work on rebind.

Found by a static analysis tool under development.

Fixes: 4676741a3464 ("memstick: rtsx_usb_ms: Fix slab-use-after-free in rtsx_usb_ms_drv_remove")
Cc: stable@vger.kernel.org # v6.10+
Co-developed-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>

---

diff --git a/drivers/memstick/host/rtsx_usb_ms.c b/drivers/memstick/host/rtsx_usb_ms.c
index d5b3a96fc609..85a681e4664b 100644
--- a/drivers/memstick/host/rtsx_usb_ms.c
+++ b/drivers/memstick/host/rtsx_usb_ms.c
@@ -820,7 +820,7 @@ static void rtsx_usb_ms_drv_remove(struct platform_device *pdev)
 	host->eject = true;
 	msh->removing = true;
 	flush_work(&host->handle_req);
-	cancel_delayed_work_sync(&host->poll_card);
+	disable_delayed_work_sync(&host->poll_card);
 
 	/* Balance possible unbalanced usage count
 	 * e.g. unconditional module removal

base-commit: 630059a5a632377b9b7b487baccde92b7ae1dd47
-- 
2.43.0


                 reply	other threads:[~2026-11-10  4:30 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=20261110043020.57040-1-mhun512@gmail.com \
    --to=mhun512@gmail.com \
    --cc=ae878000@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=maximlevitsky@gmail.com \
    --cc=oakad@yahoo.com \
    --cc=stable@vger.kernel.org \
    --cc=ulfh@kernel.org \
    /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®