FAILED: patch "[PATCH] mmc: via-sdmmc: cancel card-detect work on remove" failed to apply to 5.10-stable tree
Subsystems (2)
[email protected]
maintainerThe 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 57e5d877f898d5e5c9d672a77bb6bdd24f0d9bf5
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026090309-gerbil-rickety-e7f6@gregkh' --subject-prefix 'PATCH 5.10.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 57e5d877f898d5e5c9d672a77bb6bdd24f0d9bf5 Mon Sep 17 00:00:00 2001
From: Fan Wu <[email protected]>
Date: Thu, 23 Jul 2026 11:28:42 +0000
Subject: [PATCH] mmc: via-sdmmc: cancel card-detect work on remove
Disabling the device interrupt and freeing the IRQ prevents new card-detect work from being queued, but carddet_work already queued by the handler can still run after via_sd_remove() returns. via_sdc_card_detect() recovers the host through container_of() and dereferences its MMIO base; once remove() returns the host can be freed, so that work would touch freed memory.
Cancel carddet_work after freeing the IRQ and before cancelling finish_bh_work, which the card-detect handler can also queue. carddet_work can re-enable the interrupt through via_reset_pcictrl(); mask it again afterwards.
This issue was found by an in-house static analysis tool and confirmed by manual code review.
drivers/mmc/host/via-sdmmc.c +4 -0
@@ -1205,6 +1205,10 @@ static void via_sd_remove(struct pci_dev *pcidev)free_irq (pcidev->irq, sdhost); +cancel_work_sync (&sdhost->carddet_work); +/* carddet_work may re-enable the interrupt via via_reset_pcictrl(). */ +writeb (0x0 , sdhost->pcictrl_mmiobase +VIA_CRDR_PCIINTCTRL ); +timer_delete_sync (&sdhost->timer);cancel_work_sync (&sdhost->finish_bh_work);
Sasha Levin
maintainerPATCH 1/1 mmc: via-sdmmc: cancel card-detect work on remove
From: Fan Wu <[email protected]>
[ Upstream commit 57e5d877f898d5e5c9d672a77bb6bdd24f0d9bf5 ]
Disabling the device interrupt and freeing the IRQ prevents new card-detect work from being queued, but carddet_work already queued by the handler can still run after via_sd_remove() returns. via_sdc_card_detect() recovers the host through container_of() and dereferences its MMIO base; once remove() returns the host can be freed, so that work would touch freed memory.
Cancel carddet_work after freeing the IRQ and before cancelling finish_bh_work, which the card-detect handler can also queue. carddet_work can re-enable the interrupt through via_reset_pcictrl(); mask it again afterwards.
This issue was found by an in-house static analysis tool and confirmed by manual code review.
--- drivers/mmc/host/via-sdmmc.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mmc/host/via-sdmmc.c +4 -0
@@ -1205,6 +1205,10 @@ static void via_sd_remove(struct pci_dev *pcidev)free_irq (pcidev->irq, sdhost); +cancel_work_sync (&sdhost->carddet_work); +/* carddet_work may re-enable the interrupt via via_reset_pcictrl(). */ +writeb (0x0 , sdhost->pcictrl_mmiobase +VIA_CRDR_PCIINTCTRL ); +del_timer_sync (&sdhost->timer);tasklet_kill (&sdhost->finish_tasklet);
Signature · 1 line
2.53.0