linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>,
	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
Subject: Re: [PATCH 08/10] net: fjes: Handle return value of platform_get_irq and platform_get_resource
Date: Sat, 2 Dec 2017 23:06:09 +0300	[thread overview]
Message-ID: <1bbebd1a-4cca-0ef0-bdc1-ae50a4218f30@cogentembedded.com> (raw)
In-Reply-To: <1512242782-7134-9-git-send-email-arvind.yadav.cs@gmail.com>

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 <arvind.yadav.cs@gmail.com>
> ---
>   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

  reply	other threads:[~2017-12-02 20:06 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-02 19:26 [PATCH 00/10] Handle return value of platform_get_* Arvind Yadav
2017-12-02 19:26 ` [PATCH 01/10] net: bcmgenet: Fix platform_get_irq's error checking Arvind Yadav
2017-12-02 19:26 ` [PATCH 02/10] net: bcmgenet: free netdev on of_match_node() error Arvind Yadav
2017-12-05  1:05   ` Doug Berger
2017-12-02 19:26 ` [PATCH 03/10] net: ezchip: nps_enet: Fix platform_get_irq's error checking Arvind Yadav
2017-12-04 16:20   ` David Miller
2017-12-04 16:24     ` Russell King - ARM Linux
2017-12-04 16:34       ` David Miller
2017-12-04 16:42         ` Russell King - ARM Linux
2017-12-04 16:44           ` arvindY
2017-12-02 19:26 ` [PATCH 04/10] can: xilinx: Handle return value of platform_get_irq Arvind Yadav
2017-12-02 19:26 ` [PATCH 05/10] net: ethernet: i825xx: Fix platform_get_irq's error checking Arvind Yadav
2017-12-02 20:08   ` Sergei Shtylyov
2017-12-02 20:22     ` arvindY
2017-12-02 19:26 ` [PATCH 06/10] net: ethernet: natsemi: Handle return value of platform_get_irq Arvind Yadav
2017-12-02 19:26 ` [PATCH 07/10] net: ethernet: smsc: " Arvind Yadav
2017-12-02 20:06   ` Sergei Shtylyov
2017-12-02 19:26 ` [PATCH 08/10] net: fjes: Handle return value of platform_get_irq and platform_get_resource Arvind Yadav
2017-12-02 20:06   ` Sergei Shtylyov [this message]
2017-12-02 20:26     ` arvindY
2017-12-02 19:26 ` [PATCH 09/10] net: ethernet: korina: Handle return value of platform_get_irq_byname Arvind Yadav
2017-12-02 19:26 ` [PATCH 10/10] net: ethernet: cpmac: " Arvind Yadav

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bbebd1a-4cca-0ef0-bdc1-ae50a4218f30@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=Vladislav.Zakharov@synopsys.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=opendmb@gmail.com \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).