diff options
author | Yang Yingliang <yangyingliang@huawei.com> | 2021-06-07 22:55:21 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-19 08:53:10 +0200 |
commit | 2ee8e85ea87ed0056d405fd1293166a7d9e1f820 (patch) | |
tree | b0d4530fcb21bf42b897bcf7a3896e300eaf828b | |
parent | 80240ded7994b3b0a521e6daef88a58db7bf1bdd (diff) | |
download | linux-stable-2ee8e85ea87ed0056d405fd1293166a7d9e1f820.tar.gz linux-stable-2ee8e85ea87ed0056d405fd1293166a7d9e1f820.tar.bz2 linux-stable-2ee8e85ea87ed0056d405fd1293166a7d9e1f820.zip |
net: micrel: check return value after calling platform_get_resource()
[ Upstream commit 20f1932e2282c58cb5ac59517585206cf5b385ae ]
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>
-rw-r--r-- | drivers/net/ethernet/micrel/ks8842.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/net/ethernet/micrel/ks8842.c b/drivers/net/ethernet/micrel/ks8842.c index da329ca115cc..fb838e29d52d 100644 --- a/drivers/net/ethernet/micrel/ks8842.c +++ b/drivers/net/ethernet/micrel/ks8842.c @@ -1136,6 +1136,10 @@ static int ks8842_probe(struct platform_device *pdev) unsigned i; iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!iomem) { + dev_err(&pdev->dev, "Invalid resource\n"); + return -EINVAL; + } if (!request_mem_region(iomem->start, resource_size(iomem), DRV_NAME)) goto err_mem_region; |