Skip to content

Commit 62c59a8

Browse files
Kai-Heng FengUlf Hansson
authored andcommitted
memstick: Skip allocating card when removing host
After commit 6827ca5 ("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: 6827ca5 ("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>
1 parent 14801c6 commit 62c59a8

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/memstick/core/memstick.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,9 @@ static void memstick_check(struct work_struct *work)
441441
} else if (host->card->stop)
442442
host->card->stop(host->card);
443443

444+
if (host->removing)
445+
goto out_power_off;
446+
444447
card = memstick_alloc_card(host);
445448

446449
if (!card) {
@@ -545,6 +548,7 @@ EXPORT_SYMBOL(memstick_add_host);
545548
*/
546549
void memstick_remove_host(struct memstick_host *host)
547550
{
551+
host->removing = 1;
548552
flush_workqueue(workqueue);
549553
mutex_lock(&host->lock);
550554
if (host->card)

include/linux/memstick.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ struct memstick_host {
281281

282282
struct memstick_dev *card;
283283
unsigned int retries;
284+
bool removing;
284285

285286
/* Notify the host that some requests are pending. */
286287
void (*request)(struct memstick_host *host);

0 commit comments

Comments
 (0)