Skip to content

Commit bb6b50f

Browse files
jhovoldgregkh
authored andcommitted
spi: mpc52xx: fix use-after-free on unbind
commit 706b3dc upstream. The state machine work is scheduled by the interrupt handler and therefore needs to be cancelled after disabling interrupts to avoid a potential use-after-free. Fixes: 9848366 ("spi: mpc52xx: Add cancel_work_sync before module remove") Cc: stable@vger.kernel.org Cc: Pei Xiao <xiaopei01@kylinos.cn> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260414134319.978196-5-johan@kernel.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 59abb87 commit bb6b50f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

drivers/spi/spi-mpc52xx.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,10 +519,11 @@ static void mpc52xx_spi_remove(struct platform_device *op)
519519
struct mpc52xx_spi *ms = spi_master_get_devdata(master);
520520
int i;
521521

522-
cancel_work_sync(&ms->work);
523522
free_irq(ms->irq0, ms);
524523
free_irq(ms->irq1, ms);
525524

525+
cancel_work_sync(&ms->work);
526+
526527
for (i = 0; i < ms->gpio_cs_count; i++)
527528
gpiod_put(ms->gpio_cs[i]);
528529

0 commit comments

Comments
 (0)