From: Yang Yingliang Date: Thu, 10 Jun 2021 08:02:43 +0000 (+0800) Subject: fjes: check return value after calling platform_get_resource() X-Git-Tag: Ubuntu-5.4.0-85.95~654 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=4400b9da63d1ae5735931735b82777e7d2a8df25;p=mirror_ubuntu-focal-kernel.git fjes: check return value after calling platform_get_resource() 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin Signed-off-by: Kamal Mostafa Signed-off-by: Stefan Bader --- diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c index 91a1059517f5..b89b4a3800a4 100644 --- a/drivers/net/fjes/fjes_main.c +++ b/drivers/net/fjes/fjes_main.c @@ -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);