phy: hix5hd2-sata: Check return value of platform_get_resource

This prevent NULL pointer dereference if res is NULL.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Zhangfei Gao <zhangfei.gao@linaro.org>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
This commit is contained in:
Axel Lin 2015-03-02 16:10:54 +08:00 committed by Kishon Vijay Abraham I
parent 0f9722e37f
commit 1cbdfc48c3
1 changed files with 3 additions and 0 deletions

View File

@ -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;