From ccdbddfeff58788f7887f39a681b73c3d95b1d2f Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Wed, 30 Dec 2015 22:16:38 +0800 Subject: gpio: davinci: use irq_data_get_chip_type Use irq_data_get_chip_type() instead of container_of(). Signed-off-by: Geliang Tang Reviewed-by: Grygorii Strashko Acked-by: Santosh Shilimkar Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/gpio/gpio-davinci.c') diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index ec58f4288649..845edffbcc3f 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -432,8 +432,7 @@ static struct irq_chip *davinci_gpio_get_irq_chip(unsigned int irq) { static struct irq_chip_type gpio_unbanked; - gpio_unbanked = *container_of(irq_get_chip(irq), - struct irq_chip_type, chip); + gpio_unbanked = *irq_data_get_chip_type(irq_get_irq_data(irq)); return &gpio_unbanked.chip; }; -- cgit From d6f434e8585ac5e4256d894819bf76d02bc2ed3c Mon Sep 17 00:00:00 2001 From: Nicholas Krause Date: Tue, 2 Feb 2016 19:17:59 -0500 Subject: gpio: davinci: Fix possible NULL pointer deference This fixes a possible NULL pointer deference in the function, davinci_gpio_probe due to the function, gpio2regs being able to return a NULL pointer if it rans to get the registers for the gpio devices on a davinci board. Furthermore if this does arise return -ENXIO to signal callers that this case has arisen and avoiding setting the regs or other pointer values on the Signed-off-by: Nicholas Krause Reviewed-by: Alexandre Courbot Signed-off-by: Linus Walleij --- drivers/gpio/gpio-davinci.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/gpio/gpio-davinci.c') diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index 845edffbcc3f..96332f19e775 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -257,6 +257,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) spin_lock_init(&chips[i].lock); regs = gpio2regs(base); + if (!regs) + return -ENXIO; chips[i].regs = regs; chips[i].set_data = ®s->set_data; chips[i].clr_data = ®s->clr_data; -- cgit