Skip to content

Commit

Permalink
memstick: Skip allocating card when removing host
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
khfeng authored and storulf committed Sep 28, 2020
1 parent 14801c6 commit 62c59a8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/memstick/core/memstick.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ static void memstick_check(struct work_struct *work)
} else if (host->card->stop)
host->card->stop(host->card);

if (host->removing)
goto out_power_off;

card = memstick_alloc_card(host);

if (!card) {
Expand Down Expand Up @@ -545,6 +548,7 @@ EXPORT_SYMBOL(memstick_add_host);
*/
void memstick_remove_host(struct memstick_host *host)
{
host->removing = 1;
flush_workqueue(workqueue);
mutex_lock(&host->lock);
if (host->card)
Expand Down
1 change: 1 addition & 0 deletions include/linux/memstick.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ struct memstick_host {

struct memstick_dev *card;
unsigned int retries;
bool removing;

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

0 comments on commit 62c59a8

Please sign in to comment.