]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: mpc52xx: fix use-after-free on registration failure
authorJohan Hovold <johan@kernel.org>
Tue, 21 Apr 2026 12:58:00 +0000 (14:58 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 17 May 2026 15:16:29 +0000 (17:16 +0200)
commit f62c060272b9d7423b1650b844e8e4e7b8f9f925 upstream.

Make sure to disable and free the interrupts in case controller
registration fails to avoid a potential use-after-free and resource
leak.

This issue was flagged by Sashiko when reviewing a controller
deregistration fix.

Fixes: 42bbb70980f3 ("powerpc/5200: Add mpc5200-spi (non-PSC) device driver")
Cc: stable@vger.kernel.org # 2.6.33
Cc: Grant Likely <grant.likely@secretlab.ca>
Link: https://sashiko.dev/#/patchset/20260414134319.978196-1-johan%40kernel.org?part=3
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://patch.msgid.link/20260421125800.1537361-1-johan@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/spi/spi-mpc52xx.c

index 05bbd3795e7d802e559bf8a85551712f5b0cd380..afef72896e65e7634b33a71cc23a80f67ca16218 100644 (file)
@@ -498,6 +498,9 @@ static int mpc52xx_spi_probe(struct platform_device *op)
 
  err_register:
        dev_err(&ms->host->dev, "initialization failed\n");
+       free_irq(ms->irq0, ms);
+       free_irq(ms->irq1, ms);
+       cancel_work_sync(&ms->work);
  err_gpio:
        while (i-- > 0)
                gpiod_put(ms->gpio_cs[i]);