[PATCH] nfc: nxp-nci: Add remove on IRQ error

Greg Kroah-Hartman <[email protected]> Tue, 7 Jul 2026 16:23:27 +0200
Newsgroups dev.linux.lists.oe-linux-nfc,org.kernel.vger.linux-kernel
Message-ID <2026070726-observer-fang-9716@gregkh>
From: Griffin Kroah-Hartman <[email protected]>

Add a call to nxp_nci_remove() in nxp_nci_i2c_probe() when the
request_threaded_irq() fails.
Previously, IRQ resources were not being freed upon error.

Assisted-by: gkh_clanker_2000
Cc: David Heidelberg <[email protected]>
Cc: Carl Lee <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Ian Ray <[email protected]>
Cc: "Uwe Kleine-König (The Capable Hub)" <[email protected]>
Signed-off-by: Griffin Kroah-Hartman <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
---
 drivers/nfc/nxp-nci/i2c.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/nfc/nxp-nci/i2c.c b/drivers/nfc/nxp-nci/i2c.c
index faebc89a7ef5..564f38735510 100644
--- a/drivers/nfc/nxp-nci/i2c.c
+++ b/drivers/nfc/nxp-nci/i2c.c
@@ -334,8 +334,10 @@ static int nxp_nci_i2c_probe(struct i2c_client *client)
 				 nxp_nci_i2c_irq_thread_fn,
 				 irqflags | IRQF_ONESHOT,
 				 NXP_NCI_I2C_DRIVER_NAME, phy);
-	if (r < 0)
+	if (r < 0) {
 		nfc_err(&client->dev, "Unable to register IRQ handler\n");
+		nxp_nci_remove(phy->ndev);
+	}
 
 	return r;
 }
-- 
2.55.0