public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Mark Brown <broonie@kernel.org>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Johan Hovold <johan@kernel.org>,
	stable@vger.kernel.org, Grant Likely <grant.likely@secretlab.ca>,
	Luotao Fu <l.fu@pengutronix.de>
Subject: [PATCH 3/8] spi: mpc52xx: fix controller deregistration
Date: Tue, 14 Apr 2026 15:43:14 +0200	[thread overview]
Message-ID: <20260414134319.978196-4-johan@kernel.org> (raw)
In-Reply-To: <20260414134319.978196-1-johan@kernel.org>

Make sure to deregister the controller before disabling and releasing
underlying resources like interrupts and gpios during driver unbind.

Fixes: 42bbb70980f3 ("powerpc/5200: Add mpc5200-spi (non-PSC) device driver")
Fixes: b8d4e2ce60b6 ("mpc52xx_spi: add gpio chipselect")
Cc: stable@vger.kernel.org	# 2.6.33
Cc: Grant Likely <grant.likely@secretlab.ca>
Cc: Luotao Fu <l.fu@pengutronix.de>
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/spi/spi-mpc52xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-mpc52xx.c b/drivers/spi/spi-mpc52xx.c
index 05bbd3795e7d..823b49f8ece2 100644
--- a/drivers/spi/spi-mpc52xx.c
+++ b/drivers/spi/spi-mpc52xx.c
@@ -517,6 +517,8 @@ static void mpc52xx_spi_remove(struct platform_device *op)
 	struct mpc52xx_spi *ms = spi_controller_get_devdata(host);
 	int i;
 
+	spi_unregister_controller(host);
+
 	cancel_work_sync(&ms->work);
 	free_irq(ms->irq0, ms);
 	free_irq(ms->irq1, ms);
@@ -525,7 +527,6 @@ static void mpc52xx_spi_remove(struct platform_device *op)
 		gpiod_put(ms->gpio_cs[i]);
 
 	kfree(ms->gpio_cs);
-	spi_unregister_controller(host);
 	iounmap(ms->regs);
 	spi_controller_put(host);
 }
-- 
2.52.0


  parent reply	other threads:[~2026-04-14 13:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-14 13:43 [PATCH 0/8] spi: fix explicit controller deregistration Johan Hovold
2026-04-14 13:43 ` [PATCH 1/8] spi: cadence: fix " Johan Hovold
2026-04-14 13:43 ` [PATCH 2/8] spi: cadence-quadspi: " Johan Hovold
2026-04-14 13:43 ` Johan Hovold [this message]
2026-04-14 13:43 ` [PATCH 4/8] spi: mpc52xx: fix use-after-free on unbind Johan Hovold
2026-04-14 13:43 ` [PATCH 5/8] spi: mxic: fix controller deregistration Johan Hovold
2026-04-14 13:43 ` [PATCH 6/8] spi: orion: " Johan Hovold
2026-04-14 13:43 ` [PATCH 7/8] spi: topcliff-pch: " Johan Hovold
2026-04-14 13:43 ` [PATCH 8/8] spi: topcliff-pch: fix use-after-free on unbind Johan Hovold

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260414134319.978196-4-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=broonie@kernel.org \
    --cc=grant.likely@secretlab.ca \
    --cc=l.fu@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox