From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932239AbbCMMCS (ORCPT ); Fri, 13 Mar 2015 08:02:18 -0400 Received: from bear.ext.ti.com ([192.94.94.41]:41739 "EHLO bear.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932129AbbCMMCP (ORCPT ); Fri, 13 Mar 2015 08:02:15 -0400 From: Kishon Vijay Abraham I To: CC: , Subject: [PATCH 09/20] phy: hix5hd2-sata: Check return value of platform_get_resource Date: Fri, 13 Mar 2015 17:31:46 +0530 Message-ID: <1426248117-14312-10-git-send-email-kishon@ti.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1426248117-14312-1-git-send-email-kishon@ti.com> References: <1426248117-14312-1-git-send-email-kishon@ti.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Axel Lin This prevent NULL pointer dereference if res is NULL. Signed-off-by: Axel Lin Acked-by: Zhangfei Gao Signed-off-by: Kishon Vijay Abraham I --- 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