irqchip: madera: Check irq_dev before dereferencing
authorCharles Keepax <ckeepax@opensource.cirrus.com>
Mon, 11 Dec 2017 14:11:01 +0000 (14:11 +0000)
committer강신형 <s47.kang@samsung.com>
Tue, 19 Jun 2018 07:56:52 +0000 (16:56 +0900)
We should check if irq_dev is valid before we dereference it by passing
it to dev_get_drvdata.

Change-Id: Ifc0cae729de342f4d2828af7c51b3d0b855b6342
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
drivers/irqchip/irq-madera.c

index 51353f80310ac54a33dce5d490f2af65b570fe67..efa08f57b32ed89b622c8842c37aaade6e9b75f3 100644 (file)
@@ -110,11 +110,13 @@ static const struct regmap_irq_chip madera_irq = {
 
 static int madera_map_irq(struct madera *madera, int irq)
 {
-       struct madera_irq_priv *priv = dev_get_drvdata(madera->irq_dev);
+       struct madera_irq_priv *priv;
 
        if (!madera->irq_dev)
                return -ENOENT;
 
+       priv = dev_get_drvdata(madera->irq_dev);
+
        return regmap_irq_get_virq(priv->irq_data, irq);
 }