]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
gpio: aspeed: fix a potential NULL pointer dereference
authorKangjie Lu <kjlu@umn.edu>
Sun, 24 Mar 2019 23:10:02 +0000 (18:10 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1838459
[ Upstream commit 6cf4511e9729c00a7306cf94085f9cc3c52ee723 ]

In case devm_kzalloc, the patch returns ENOMEM to avoid potential
NULL pointer dereference.

Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/gpio/gpio-aspeed.c

index cd811879f132fa0e199400635b472ef7529f5e38..a659f9ccd6fabc237b738141cb53647325407ff4 100644 (file)
@@ -864,6 +864,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
 
        gpio->offset_timer =
                devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL);
+       if (!gpio->offset_timer)
+               return -ENOMEM;
 
        return aspeed_gpio_setup_irqs(gpio, pdev);
 }