public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] phy: hix5hd2-sata: Check return value of platform_get_resource
@ 2015-03-02  8:10 Axel Lin
  2015-03-02  8:19 ` zhangfei
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2015-03-02  8:10 UTC (permalink / raw)
  To: Kishon Vijay Abraham I
  Cc: Jiancheng Xue, Zhangfei Gao, linux-kernel@vger.kernel.org

This prevent NULL pointer dereference if res is NULL.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
---
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




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-03-02  8:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-02  8:10 [PATCH] phy: hix5hd2-sata: Check return value of platform_get_resource Axel Lin
2015-03-02  8:19 ` zhangfei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox