Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752211AbdLBUGP (ORCPT ); Sat, 2 Dec 2017 15:06:15 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45051 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752027AbdLBUGN (ORCPT ); Sat, 2 Dec 2017 15:06:13 -0500 X-Google-Smtp-Source: AGs4zMb2FLuB4r9hZHsN0IQt3QUUxrtumu0p8KwN733Bj8JeJQKv7Q6YoKTcSkm/qdh2mwIfOoXheQ== Subject: Re: [PATCH 08/10] net: fjes: Handle return value of platform_get_irq and platform_get_resource To: Arvind Yadav , wg@grandegger.com, mkl@pengutronix.de, michal.simek@xilinx.com, opendmb@gmail.com, f.fainelli@gmail.com, davem@davemloft.net, Vladislav.Zakharov@synopsys.com Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org References: <1512242782-7134-1-git-send-email-arvind.yadav.cs@gmail.com> <1512242782-7134-9-git-send-email-arvind.yadav.cs@gmail.com> From: Sergei Shtylyov Organization: Cogent Embedded Message-ID: <1bbebd1a-4cca-0ef0-bdc1-ae50a4218f30@cogentembedded.com> Date: Sat, 2 Dec 2017 23:06:09 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1512242782-7134-9-git-send-email-arvind.yadav.cs@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-MW Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1266 Lines: 46 Hello! On 12/02/2017 10:26 PM, Arvind Yadav wrote: > platform_get_irq() and platform_get_resource() can fail here and > we must check its return value. > > Signed-off-by: Arvind Yadav > --- > drivers/net/fjes/fjes_main.c | 10 ++++++++++ > 1 file changed, 10 insertions(+) > > diff --git a/drivers/net/fjes/fjes_main.c b/drivers/net/fjes/fjes_main.c > index 750954b..540dd51 100644 > --- a/drivers/net/fjes/fjes_main.c > +++ b/drivers/net/fjes/fjes_main.c > @@ -1265,9 +1265,19 @@ static int fjes_probe(struct platform_device *plat_dev) > adapter->interrupt_watch_enable = false; > > res = platform_get_resource(plat_dev, IORESOURCE_MEM, 0); > + if (!res) { > + err = -EINVAL; > + goto err_free_netdev; > + } > + > hw->hw_res.start = res->start; > hw->hw_res.size = resource_size(res); > hw->hw_res.irq = platform_get_irq(plat_dev, 0); > + if (hw->hw_res.irq <= 0) { This function no longer returns 0 on error, no need to check for <= 0. > + err = hw->hw_res.irq ? hw->hw_res.irq : -ENODEV; > + goto err_free_netdev; gcc allows a shorter way to write that. err = hw->hw_res.irq ?: -ENODEV; > + } > + > err = fjes_hw_init(&adapter->hw); > if (err) > goto err_free_netdev; MBR, Sergei