nfc: fdp: fix NULL pointer dereference
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Tue, 20 Dec 2016 21:09:04 +0000 (21:09 +0000)
committerSamuel Ortiz <sameo@linux.intel.com>
Sat, 1 Apr 2017 22:36:12 +0000 (00:36 +0200)
We are checking phy after dereferencing it. We can print the debug
information after checking it. If phy is NULL then we will get a good
stack trace to tell us that we are in this irq handler.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/fdp/i2c.c

index 5e797d5c38edce00356702bde47814a30d651d80..712936f5d2d64a200f16a28e044aeb4a362dc7ff 100644 (file)
@@ -210,14 +210,14 @@ static irqreturn_t fdp_nci_i2c_irq_thread_fn(int irq, void *phy_id)
        struct sk_buff *skb;
        int r;
 
-       client = phy->i2c_dev;
-       dev_dbg(&client->dev, "%s\n", __func__);
-
        if (!phy || irq != phy->i2c_dev->irq) {
                WARN_ON_ONCE(1);
                return IRQ_NONE;
        }
 
+       client = phy->i2c_dev;
+       dev_dbg(&client->dev, "%s\n", __func__);
+
        r = fdp_nci_i2c_read(phy, &skb);
 
        if (r == -EREMOTEIO)