]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
fjes: check return value after calling platform_get_resource()
authorYang Yingliang <yangyingliang@huawei.com>
Thu, 10 Jun 2021 08:02:43 +0000 (16:02 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 13 Aug 2021 07:46:38 +0000 (09:46 +0200)
BugLink: https://bugs.launchpad.net/bugs/1938713
[ Upstream commit f18c11812c949553d2b2481ecaa274dd51bed1e7 ]

It will cause null-ptr-deref if platform_get_resource() returns NULL,
we need check the return value.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/net/fjes/fjes_main.c

index 91a1059517f55adc66cbeaed328a6077fa47b0d1..b89b4a3800a4d579da654f813670cf59a200a986 100644 (file)
@@ -1262,6 +1262,10 @@ static int fjes_probe(struct platform_device *plat_dev)
        adapter->interrupt_watch_enable = false;
 
        res = platform_get_resource(plat_dev, IORESOURCE_MEM, 0);
+       if (!res) {
+               err = -EINVAL;
+               goto err_free_control_wq;
+       }
        hw->hw_res.start = res->start;
        hw->hw_res.size = resource_size(res);
        hw->hw_res.irq = platform_get_irq(plat_dev, 0);