public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Masahiro Yamada <masahiroy@kernel.org>
Cc: "David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Miguel Ojeda <ojeda@kernel.org>, Arnd Bergmann <arnd@arndb.de>,
	Heiner Kallweit <hkallweit1@gmail.com>
Subject: Re: [PATCH] net: lantiq_etop: check the result of request_irq()
Date: Mon, 21 Dec 2020 16:26:45 +0100	[thread overview]
Message-ID: <20201221152645.GH3026679@lunn.ch> (raw)
In-Reply-To: <20201221054323.247483-1-masahiroy@kernel.org>

On Mon, Dec 21, 2020 at 02:43:23PM +0900, Masahiro Yamada wrote:
> The declaration of request_irq() in <linux/interrupt.h> is marked as
> __must_check.
> 
> Without the return value check, I see the following warnings:
> 
> drivers/net/ethernet/lantiq_etop.c: In function 'ltq_etop_hw_init':
> drivers/net/ethernet/lantiq_etop.c:273:4: warning: ignoring return value of 'request_irq', declared with attribute warn_unused_result [-Wunused-result]
>   273 |    request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv);
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/net/ethernet/lantiq_etop.c:281:4: warning: ignoring return value of 'request_irq', declared with attribute warn_unused_result [-Wunused-result]
>   281 |    request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv);
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Reported-by: Miguel Ojeda <ojeda@kernel.org>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  drivers/net/ethernet/lantiq_etop.c | 13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c
> index 2d0c52f7106b..960494f9752b 100644
> --- a/drivers/net/ethernet/lantiq_etop.c
> +++ b/drivers/net/ethernet/lantiq_etop.c
> @@ -264,13 +264,18 @@ ltq_etop_hw_init(struct net_device *dev)
>  	for (i = 0; i < MAX_DMA_CHAN; i++) {
>  		int irq = LTQ_DMA_CH0_INT + i;
>  		struct ltq_etop_chan *ch = &priv->ch[i];
> +		int ret;
>  
>  		ch->idx = ch->dma.nr = i;
>  		ch->dma.dev = &priv->pdev->dev;
>  
>  		if (IS_TX(i)) {
>  			ltq_dma_alloc_tx(&ch->dma);
> -			request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv);
> +			ret = request_irq(irq, ltq_etop_dma_irq, 0, "etop_tx", priv);
> +			if (ret) {
> +				netdev_err(dev, "failed to request irq\n");
> +				return ret;

You need to cleanup what ltq_dma_alloc_tx() did.

> +			}
>  		} else if (IS_RX(i)) {
>  			ltq_dma_alloc_rx(&ch->dma);
>  			for (ch->dma.desc = 0; ch->dma.desc < LTQ_DESC_NUM;
> @@ -278,7 +283,11 @@ ltq_etop_hw_init(struct net_device *dev)
>  				if (ltq_etop_alloc_skb(ch))
>  					return -ENOMEM;
>  			ch->dma.desc = 0;
> -			request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv);
> +			ret = request_irq(irq, ltq_etop_dma_irq, 0, "etop_rx", priv);
> +			if (ret) {
> +				netdev_err(dev, "failed to request irq\n");
> +				return ret;

And here you need to cleanup ltq_dma_alloc_rx().

    Andrew

  reply	other threads:[~2020-12-21 15:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-21  5:43 [PATCH] net: lantiq_etop: check the result of request_irq() Masahiro Yamada
2020-12-21 15:26 ` Andrew Lunn [this message]
2020-12-21 15:59   ` Masahiro Yamada
2020-12-21 17:01     ` Andrew Lunn
2020-12-21 17:38       ` Miguel Ojeda
2020-12-21 18:04     ` Andrew Lunn
2020-12-21 23:41       ` Hauke Mehrtens

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=20201221152645.GH3026679@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=ojeda@kernel.org \
    /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