Skip to contentSkip to conversation

gpio: grgpio: Avoid potential NULL pointer dereference

PATCH In review Axel Lin 2 participants 2 messages Dec 20, 2014 – Jan 8, 2015 GPIO

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: grgpio: Avoid potential NULL pointer dereference

irqmap is optional property, so priv->domain can be NULL if !irqmap. Thus add NULL test for priv->domain before calling irq_domain_remove() to prevent NULL pointer dereference.

---
 drivers/gpio/gpio-grgpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpio/gpio-grgpio.c +2 -1
index 09daaf2..3a5a710 100644
@@ -441,7 +441,8 @@ static int grgpio_probe(struct platform_device *ofdev)
 	err = gpiochip_add(gc);
 	if (err) {
 		dev_err(&ofdev->dev, "Could not add gpiochip\n");
-		irq_domain_remove(priv->domain);
+		if (priv->domain)
+			irq_domain_remove(priv->domain);
 		return err;
 	}
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 5 lines · Axel Lin

irqmap is optional property, so priv->domain can be NULL if !irqmap. Thus add NULL test for priv->domain before calling irq_domain_remove() to prevent NULL pointer dereference.

Patch applied for fixes. Thanks!

Yours,
Linus Walleij