summaryrefslogtreecommitdiffstats
path: root/drivers/nfc
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2015-01-25 23:33:29 +0100
committerSamuel Ortiz <sameo@linux.intel.com>2015-01-26 23:14:34 +0100
commit7274496f2e1e799dbc260d7465e32077cb1a3fd6 (patch)
tree9ff398eb60545644a165764116597ded5a4fffb4 /drivers/nfc
parentc490c557b67fddfc7d733455d86500080ba717b6 (diff)
downloadlinux-7274496f2e1e799dbc260d7465e32077cb1a3fd6.tar.bz2
NFC: st21nfcb: Fix "NULL pointer dereference" possible error
When the platform with CONFIG_ST21NFCB_I2C=y without any st21nfcb component physically connected a: "Unable to handle kernel NULL pointer dereference at virtual address" may show up at driver initialization phase. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r--drivers/nfc/st21nfcb/i2c.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/drivers/nfc/st21nfcb/i2c.c b/drivers/nfc/st21nfcb/i2c.c
index b65847c62631..eb886932d972 100644
--- a/drivers/nfc/st21nfcb/i2c.c
+++ b/drivers/nfc/st21nfcb/i2c.c
@@ -199,7 +199,7 @@ static irqreturn_t st21nfcb_nci_irq_thread_fn(int irq, void *phy_id)
struct sk_buff *skb = NULL;
int r;
- if (!phy || irq != phy->i2c_dev->irq) {
+ if (!phy || !phy->ndlc || irq != phy->i2c_dev->irq) {
WARN_ON_ONCE(1);
return IRQ_NONE;
}
@@ -343,18 +343,22 @@ static int st21nfcb_nci_i2c_probe(struct i2c_client *client,
return -ENODEV;
}
+ r = ndlc_probe(phy, &i2c_phy_ops, &client->dev,
+ ST21NFCB_FRAME_HEADROOM, ST21NFCB_FRAME_TAILROOM,
+ &phy->ndlc);
+ if (r < 0) {
+ nfc_err(&client->dev, "Unable to register ndlc layer\n");
+ return r;
+ }
+
r = devm_request_threaded_irq(&client->dev, client->irq, NULL,
st21nfcb_nci_irq_thread_fn,
phy->irq_polarity | IRQF_ONESHOT,
ST21NFCB_NCI_DRIVER_NAME, phy);
- if (r < 0) {
+ if (r < 0)
nfc_err(&client->dev, "Unable to register IRQ handler\n");
- return r;
- }
- return ndlc_probe(phy, &i2c_phy_ops, &client->dev,
- ST21NFCB_FRAME_HEADROOM, ST21NFCB_FRAME_TAILROOM,
- &phy->ndlc);
+ return r;
}
static int st21nfcb_nci_i2c_remove(struct i2c_client *client)