[PATCH] nfc: st-nci: Add error handling to IRQ handlers

From: Greg Kroah-Hartman

Date: Tue Jul 07 2026 - 10:40:55 EST


From: Griffin Kroah-Hartman <griffin@xxxxxxxxx>

Add ndlc_remove() to st_nci_i2c_probe() and st_nci_spi_probe() if the
devm_request_threaded_irq() function fails. This is to properly unwind
after ndlc_probe() was called prior to this.

Assisted-by: gkh_clanker_2000
Cc: David Heidelberg <david@xxxxxxx>
Cc: "Uwe Kleine-König (The Capable Hub)" <u.kleine-koenig@xxxxxxxxxxxx>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
Signed-off-by: Griffin Kroah-Hartman <griffin@xxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
drivers/nfc/st-nci/i2c.c | 4 +++-
drivers/nfc/st-nci/spi.c | 4 +++-
2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nfc/st-nci/i2c.c b/drivers/nfc/st-nci/i2c.c
index 9ae839a6f5cc..7f727d9b97ba 100644
--- a/drivers/nfc/st-nci/i2c.c
+++ b/drivers/nfc/st-nci/i2c.c
@@ -243,8 +243,10 @@ static int st_nci_i2c_probe(struct i2c_client *client)
st_nci_irq_thread_fn,
IRQF_ONESHOT,
ST_NCI_DRIVER_NAME, phy);
- if (r < 0)
+ if (r < 0) {
nfc_err(&client->dev, "Unable to register IRQ handler\n");
+ ndlc_remove(phy->ndlc);
+ }

return r;
}
diff --git a/drivers/nfc/st-nci/spi.c b/drivers/nfc/st-nci/spi.c
index 169eacc0a32a..6f1ffd8244fa 100644
--- a/drivers/nfc/st-nci/spi.c
+++ b/drivers/nfc/st-nci/spi.c
@@ -257,8 +257,10 @@ static int st_nci_spi_probe(struct spi_device *dev)
st_nci_irq_thread_fn,
IRQF_ONESHOT,
ST_NCI_SPI_DRIVER_NAME, phy);
- if (r < 0)
+ if (r < 0) {
nfc_err(&dev->dev, "Unable to register IRQ handler\n");
+ ndlc_remove(phy->ndlc);
+ }

return r;
}
--
2.55.0