Skip to content

Commit

Permalink
gpio: zynq: Check return value of irq_get_irq_data
Browse files Browse the repository at this point in the history
[ Upstream commit 35d7b72 ]

In two different instances the return value of "irq_get_irq_data"
API was neither captured nor checked.
Fixed it by capturing the return value and then checking for any error.

Addresses-Coverity: "returned_null"
Signed-off-by: Srinivas Neeli <srinivas.neeli@xilinx.com>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Srinivas Neeli authored and gregkh committed Jul 20, 2021
1 parent c42ec04 commit 4d18303
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/gpio/gpio-zynq.c
Expand Up @@ -736,6 +736,11 @@ static int __maybe_unused zynq_gpio_suspend(struct device *dev)
struct zynq_gpio *gpio = dev_get_drvdata(dev);
struct irq_data *data = irq_get_irq_data(gpio->irq);

if (!data) {
dev_err(dev, "irq_get_irq_data() failed\n");
return -EINVAL;
}

if (!device_may_wakeup(dev))
disable_irq(gpio->irq);

Expand All @@ -753,6 +758,11 @@ static int __maybe_unused zynq_gpio_resume(struct device *dev)
struct irq_data *data = irq_get_irq_data(gpio->irq);
int ret;

if (!data) {
dev_err(dev, "irq_get_irq_data() failed\n");
return -EINVAL;
}

if (!device_may_wakeup(dev))
enable_irq(gpio->irq);

Expand Down

0 comments on commit 4d18303

Please sign in to comment.