[PATCH 09/20] phy: hix5hd2-sata: Check return value of platform_get_resource

From: Kishon Vijay Abraham I
Date: Fri Mar 13 2015 - 08:02:20 EST


From: Axel Lin <axel.lin@xxxxxxxxxx>

This prevent NULL pointer dereference if res is NULL.

Signed-off-by: Axel Lin <axel.lin@xxxxxxxxxx>
Acked-by: Zhangfei Gao <zhangfei.gao@xxxxxxxxxx>
Signed-off-by: Kishon Vijay Abraham I <kishon@xxxxxx>
---
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.7.9.5

--
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/