Skip to contentSkip to conversation

FAILED: patch "[PATCH] memstick: ms_block: destroy io_queue workqueue on removal" failed to apply to 5.10-stable tree

PATCH New [email protected] 2 participants 2 messages Sep 22

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x 90af7fde083e1b22c349c3a8b1626728e44e474c
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026092240-eel-composure-463d@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'

Possible dependencies:

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 90af7fde083e1b22c349c3a8b1626728e44e474c Mon Sep 17 00:00:00 2001
From: Yifei Gao <[email protected]>
Date: Tue, 4 Aug 2026 21:34:56 +0000
Subject: [PATCH] memstick: ms_block: destroy io_queue workqueue on removal

msb_init_disk() creates the per-card ordered workqueue msb->io_queue with alloc_ordered_workqueue(). It is torn down with destroy_workqueue() only on the init error path; msb_remove() never destroys it. msb_stop() merely flushes the queue, and neither msb_data_clear() nor put_disk() free it. As a result every card insert/remove cycle leaks the workqueue and its kworker, exhausting kernel memory over repeated cycles.

Destroy the workqueue in msb_remove() after the disk has been removed and the queue drained.

Fixes 0ab30494bc4f ("memstick: add support for legacy memorysticks")
Assisted-by Claude:claude-opus-4-8
drivers/memstick/core/ms_block.c +2 -0
index ce33907bfc24..65154e569a9e 100644
@@ -2204,6 +2204,8 @@ static void msb_remove(struct memstick_dev *card)
 	msb_data_clear(msb);
 	mutex_unlock(&msb_disk_lock);
 
+	destroy_workqueue(msb->io_queue);
+
 	put_disk(msb->disk);
 	memstick_set_drvdata(card, NULL);
 }
maintainer
#1 lore raw

PATCH 1/1 memstick: ms_block: destroy io_queue workqueue on removal

From: Yifei Gao <[email protected]>

[ Upstream commit 90af7fde083e1b22c349c3a8b1626728e44e474c ]

msb_init_disk() creates the per-card ordered workqueue msb->io_queue with alloc_ordered_workqueue(). It is torn down with destroy_workqueue() only on the init error path; msb_remove() never destroys it. msb_stop() merely flushes the queue, and neither msb_data_clear() nor put_disk() free it. As a result every card insert/remove cycle leaks the workqueue and its kworker, exhausting kernel memory over repeated cycles.

Destroy the workqueue in msb_remove() after the disk has been removed and the queue drained.

Fixes 0ab30494bc4f ("memstick: add support for legacy memorysticks")
Assisted-by Claude:claude-opus-4-8
[ adjusted context to retain msb_disk_release() instead of upstream put_disk(). ]
---
 drivers/memstick/core/ms_block.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/memstick/core/ms_block.c +2 -0
index 1d9e83baf6414..f4c0177460b02 100644
@@ -2226,6 +2226,8 @@ static void msb_remove(struct memstick_dev *card)
 	msb_data_clear(msb);
 	mutex_unlock(&msb_disk_lock);
 
+	destroy_workqueue(msb->io_queue);
+
 	msb_disk_release(msb->disk);
 	memstick_set_drvdata(card, NULL);
 }
Signature · 1 line
2.53.0