Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

memstick: Skip allocating card when removing host

After commit 6827ca573c03 ("memstick: rtsx_usb_ms: Support runtime power
management"), removing module rtsx_usb_ms will be stuck.

The deadlock is caused by powering on and powering off at the same time,
the former one is when memstick_check() is flushed, and the later is called
by memstick_remove_host().

Soe let's skip allocating card to prevent this issue.

Fixes: 6827ca573c03 ("memstick: rtsx_usb_ms: Support runtime power management")
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Link: https://lore.kernel.org/r/20200925084952.13220-1-kai.heng.feng@canonical.com
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Kai-Heng Feng and committed by
Ulf Hansson
62c59a87 14801c62

+5
+4
drivers/memstick/core/memstick.c
··· 441 441 } else if (host->card->stop) 442 442 host->card->stop(host->card); 443 443 444 + if (host->removing) 445 + goto out_power_off; 446 + 444 447 card = memstick_alloc_card(host); 445 448 446 449 if (!card) { ··· 548 545 */ 549 546 void memstick_remove_host(struct memstick_host *host) 550 547 { 548 + host->removing = 1; 551 549 flush_workqueue(workqueue); 552 550 mutex_lock(&host->lock); 553 551 if (host->card)
+1
include/linux/memstick.h
··· 281 281 282 282 struct memstick_dev *card; 283 283 unsigned int retries; 284 + bool removing; 284 285 285 286 /* Notify the host that some requests are pending. */ 286 287 void (*request)(struct memstick_host *host);