phy: hix5hd2-sata: Check return value of platform_get_resource
PATCH 1/1 phy: hix5hd2-sata: Check return value of platform_get_resource
This prevent NULL pointer dereference if res is NULL.
Signed-off-by Axel Lin <[email protected]>
---
This patch replaces [PATCH] phy: hix5hd2-sata: Convert to use devm_ioremap_resource, as zhangfei pinted out that the memory region is shared with sata controller so devm_request_mem_region would fail.
drivers/phy/phy-hix5hd2-sata.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/phy/phy-hix5hd2-sata.c +3 -0
@@ -147,6 +147,9 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; + priv->base =devm_ioremap (dev, res->start,resource_size (res));if (!priv->base)return -ENOMEM ;
Signature · 1 line
1.9.1
Quoted 3 lines · Axel Lin
This prevent NULL pointer dereference if res is NULL.
Signed-off-by Axel Lin <[email protected]>
Acked-by Zhangfei Gao <[email protected]>
Thanks
Quoted 22 lines
---
This patch replaces [PATCH] phy: hix5hd2-sata: Convert to usedevm_ioremap_resource, as zhangfei pinted out that the memory region is shared with sata controller sodevm_request_mem_regionwould fail.drivers/phy/phy-hix5hd2-sata.c | 3 +++ 1 file changed, 3 insertions(+)drivers/phy/phy-hix5hd2-sata.c +3
-0@@ -147,6 +147,9 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)return -ENOMEM ; res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -EINVAL ; + priv->base =devm_ioremap (dev, res->start,resource_size (res));if (!priv->base)return -ENOMEM ;