[PATCH] phy: hix5hd2-sata: Check return value of platform_get_resource
From: Axel Lin
Date: Mon Mar 02 2015 - 03:11:08 EST
This prevent NULL pointer dereference if res is NULL.
Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
---
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(+)
diff --git a/drivers/phy/phy-hix5hd2-sata.c b/drivers/phy/phy-hix5hd2-sata.c
index 34915b4..d6b2265 100644
--- a/drivers/phy/phy-hix5hd2-sata.c
+++ b/drivers/phy/phy-hix5hd2-sata.c
@@ -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;
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/