From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751460AbbCBITb (ORCPT ); Mon, 2 Mar 2015 03:19:31 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:35811 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750929AbbCBITa (ORCPT ); Mon, 2 Mar 2015 03:19:30 -0500 Message-ID: <54F41D08.8000608@linaro.org> Date: Mon, 02 Mar 2015 16:19:20 +0800 From: zhangfei User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Axel Lin , Kishon Vijay Abraham I CC: Jiancheng Xue , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] phy: hix5hd2-sata: Check return value of platform_get_resource References: <1425283854.16106.0.camel@phoenix> In-Reply-To: <1425283854.16106.0.camel@phoenix> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/02/2015 04:10 PM, Axel Lin wrote: > This prevent NULL pointer dereference if res is NULL. > > Signed-off-by: Axel Lin Acked-by: Zhangfei Gao Thanks > --- > 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; >