diff mbox series

[2/2] mmc: queue: Flush recovery work on cleanup

Message ID 08aac29e2d8545a6b56e092bc508409e@hyperstone.com (mailing list archive)
State New, archived
Headers show
Series [1/2] mmc: block: Remove error check of hw_reset on reset | expand

Commit Message

Christian Loehle Oct. 6, 2022, 1:39 p.m. UTC
To prevent any recovery work running after the queue cleanup flush it.
Any recovery running post-cleanup dereferenced mq->card as NULL
and was not meaningful to begin with.

Cc: stable@vger.kernel.org

Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
---
 drivers/mmc/core/queue.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Ulf Hansson Oct. 7, 2022, 1:12 p.m. UTC | #1
On Thu, 6 Oct 2022 at 15:39, Christian Löhle <CLoehle@hyperstone.com> wrote:
>
> To prevent any recovery work running after the queue cleanup flush it.
> Any recovery running post-cleanup dereferenced mq->card as NULL
> and was not meaningful to begin with.
>
> Cc: stable@vger.kernel.org
>
> Signed-off-by: Christian Loehle <cloehle@hyperstone.com>
> ---
>  drivers/mmc/core/queue.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
> index fefaa901b50f..a1b985d3dfda 100644
> --- a/drivers/mmc/core/queue.c
> +++ b/drivers/mmc/core/queue.c
> @@ -493,6 +493,13 @@ void mmc_cleanup_queue(struct mmc_queue *mq)
>         if (blk_queue_quiesced(q))
>                 blk_mq_unquiesce_queue(q);
>
> +       /*
> +        * If the recovery completes the last (and only remaining) request in
> +        * the queue, and the card has been removed, we could end up here with
> +        * the recovery not quite finished yet, so flush it.
> +        */
> +       flush_work(&mq->recovery_work);
> +

Not sure if it really matters in this case, but isn't
cancel_work_sync() the more proper thing to call instead?

>         blk_mq_free_tag_set(&mq->tag_set);
>
>         /*

Kind regards
Uffe
diff mbox series

Patch

diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c
index fefaa901b50f..a1b985d3dfda 100644
--- a/drivers/mmc/core/queue.c
+++ b/drivers/mmc/core/queue.c
@@ -493,6 +493,13 @@  void mmc_cleanup_queue(struct mmc_queue *mq)
 	if (blk_queue_quiesced(q))
 		blk_mq_unquiesce_queue(q);
 
+	/*
+	 * If the recovery completes the last (and only remaining) request in
+	 * the queue, and the card has been removed, we could end up here with
+	 * the recovery not quite finished yet, so flush it.
+	 */
+	flush_work(&mq->recovery_work);
+
 	blk_mq_free_tag_set(&mq->tag_set);
 
 	/*