From: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx> Date: Thu, 6 Apr 2017 16:12:00 +0530 Prevent the NULL pointer access in the suspend resume. Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@xxxxxxxxxx> Signed-off-by: Michal Simek <michal.simek@xxxxxxxxxx> Signed-off-by: Alexander Hedges <ahedges@xxxxxxx> (cherry picked from commit 30b6bc689ae71b657f5e1f7fb86468b9d8edcfc2) --- drivers/gpio/gpio-xilinx.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/gpio/gpio-xilinx.c b/drivers/gpio/gpio-xilinx.c index 37e5ca9e5b6f..3848223ab460 100644 --- a/drivers/gpio/gpio-xilinx.c +++ b/drivers/gpio/gpio-xilinx.c @@ -486,9 +486,16 @@ static void xgpio_free(struct gpio_chip *chip, unsigned int offset) static int __maybe_unused xgpio_suspend(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - int irq = platform_get_irq(pdev, 0); - struct irq_data *data = irq_get_irq_data(irq); + int irq; + struct irq_data *data; + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { + dev_dbg(dev, "failed to get IRQ\n"); + return 0; + } + + data = irq_get_irq_data(irq); if (!irqd_is_wakeup_set(data)) return pm_runtime_force_suspend(dev); @@ -498,9 +505,17 @@ static int __maybe_unused xgpio_suspend(struct device *dev) static int __maybe_unused xgpio_resume(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); - int irq = platform_get_irq(pdev, 0); - struct irq_data *data = irq_get_irq_data(irq); + int irq; + struct irq_data *data; + + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) { + dev_dbg(dev, "failed to get IRQ\n"); + return 0; + } + data = irq_get_irq_data(irq); if (!irqd_is_wakeup_set(data)) return pm_runtime_force_resume(dev); -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html