diff mbox

gpio: grgpio: Avoid potential NULL pointer dereference

Message ID 1419086827.20365.1.camel@phoenix
State New, archived
Headers show

Commit Message

Axel Lin Dec. 20, 2014, 2:47 p.m. UTC
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.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
 drivers/gpio/gpio-grgpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Linus Walleij Jan. 8, 2015, 7:14 p.m. UTC | #1
On Sat, Dec 20, 2014 at 3:47 PM, Axel Lin <axel.lin@ingics.com> wrote:

> 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.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>

Patch applied for fixes. Thanks!

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpio-grgpio.c b/drivers/gpio/gpio-grgpio.c
index 09daaf2..3a5a710 100644
--- a/drivers/gpio/gpio-grgpio.c
+++ b/drivers/gpio/gpio-grgpio.c
@@ -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;
 	}