diff mbox series

net: lantiq_etop: check the result of request_irq()

Message ID 20201221054323.247483-1-masahiroy@kernel.org (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: lantiq_etop: check the result of request_irq() | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 1 maintainers not CCed: nipa@patchwork.hopto.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: line length of 85 exceeds 80 columns
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

Masahiro Yamada Dec. 21, 2020, 5:43 a.m. UTC
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(-)

Comments

Andrew Lunn Dec. 21, 2020, 3:26 p.m. UTC | #1
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
Masahiro Yamada Dec. 21, 2020, 3:59 p.m. UTC | #2
On Tue, Dec 22, 2020 at 12:26 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> 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.


Any failure from this function will roll back
in the following paths:

  ltq_etop_hw_exit()
     -> ltq_etop_free_channel()
          -> ltq_dma_free()


So, dma is freed anyway.

One problem I see is,
ltq_etop_hw_exit() frees all DMA channels,
some of which may not have been allocated yet.

If it is a bug, it is an existing bug.


>
> > +                     }
> >               } 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;


This -ENOMEM does not roll back anything here.

As stated above, dma_free_coherent() is called.
The problem is, ltq_etop_hw_exit() rolls back too much.

If your requirement is "this driver is completely wrong. Please rewrite it",
sorry, I cannot (unless I am paid to do so).

I am just following this driver's roll-back model.

Please do not expect more to a person who
volunteers to eliminate build warnings.

Of course, if somebody volunteers to rewrite this driver correctly,
that is appreciated.



> >                       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
Andrew Lunn Dec. 21, 2020, 5:01 p.m. UTC | #3
On Tue, Dec 22, 2020 at 12:59:08AM +0900, Masahiro Yamada wrote:
> On Tue, Dec 22, 2020 at 12:26 AM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > 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.
> 
> 
> Any failure from this function will roll back
> in the following paths:
> 
>   ltq_etop_hw_exit()
>      -> ltq_etop_free_channel()
>           -> ltq_dma_free()
> 
> 
> So, dma is freed anyway.

O.K, thanks for the information. 

> One problem I see is,
> ltq_etop_hw_exit() frees all DMA channels,
> some of which may not have been allocated yet.
> 
> If it is a bug, it is an existing bug.
> 
> 
> >
> > > +                     }
> > >               } 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;
> 
> 
> This -ENOMEM does not roll back anything here.
> 
> As stated above, dma_free_coherent() is called.
> The problem is, ltq_etop_hw_exit() rolls back too much.
> 
> If your requirement is "this driver is completely wrong. Please rewrite it",
> sorry, I cannot (unless I am paid to do so).
> 
> I am just following this driver's roll-back model.
> 
> Please do not expect more to a person who
> volunteers to eliminate build warnings.

There is a balance here. We should not remove a warning unless we
properly fix the warning. Otherwise having the warning is pointless.

So please leave the warning in place, and maybe somebody else will
fully fix it.

      Andrew
Miguel Ojeda Dec. 21, 2020, 5:38 p.m. UTC | #4
On Mon, Dec 21, 2020 at 6:01 PM Andrew Lunn <andrew@lunn.ch> wrote:
>
> So please leave the warning in place, and maybe somebody else will
> fully fix it.

For context: the plan is to enable the warning unconditionally
starting with 5.11. After that, the idea is making it an error as soon
as reasonable (e.g. 5.12 if no warnings remain by then).

However, if there is nobody planning to fix a given warning, then I'd
say documenting the problem with a `FIXME` comment (plus a change like
this or simply ignoring the return value) would be the best approach.

Cheers,
Miguel
Andrew Lunn Dec. 21, 2020, 6:04 p.m. UTC | #5
On Tue, Dec 22, 2020 at 12:59:08AM +0900, Masahiro Yamada wrote:
> On Tue, Dec 22, 2020 at 12:26 AM Andrew Lunn <andrew@lunn.ch> wrote:
> >
> > 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.
> 
> 
> Any failure from this function will roll back
> in the following paths:
> 
>   ltq_etop_hw_exit()
>      -> ltq_etop_free_channel()
>           -> ltq_dma_free()
> 
> 
> So, dma is freed anyway.
> 
> One problem I see is,
> ltq_etop_hw_exit() frees all DMA channels,
> some of which may not have been allocated yet.
> 
> If it is a bug, it is an existing bug.
> 
> 
> >
> > > +                     }
> > >               } 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;
> 
> 
> This -ENOMEM does not roll back anything here.
> 
> As stated above, dma_free_coherent() is called.
> The problem is, ltq_etop_hw_exit() rolls back too much.
> 
> If your requirement is "this driver is completely wrong. Please rewrite it",
> sorry, I cannot (unless I am paid to do so).
> 
> I am just following this driver's roll-back model.
> 
> Please do not expect more to a person who
> volunteers to eliminate build warnings.
> 
> Of course, if somebody volunteers to rewrite this driver correctly,
> that is appreciated.

Hi Hauke

Do you still have this hardware? Do you have time to take a look at
the cleanup code?

Thanks
	Andrew
Hauke Mehrtens Dec. 21, 2020, 11:41 p.m. UTC | #6
On 12/21/20 7:04 PM, Andrew Lunn wrote:
> On Tue, Dec 22, 2020 at 12:59:08AM +0900, Masahiro Yamada wrote:
>> On Tue, Dec 22, 2020 at 12:26 AM Andrew Lunn <andrew@lunn.ch> wrote:
>>>
>>> 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.
>>
>>
>> Any failure from this function will roll back
>> in the following paths:
>>
>>    ltq_etop_hw_exit()
>>       -> ltq_etop_free_channel()
>>            -> ltq_dma_free()
>>
>>
>> So, dma is freed anyway.
>>
>> One problem I see is,
>> ltq_etop_hw_exit() frees all DMA channels,
>> some of which may not have been allocated yet.
>>
>> If it is a bug, it is an existing bug.
>>
>>
>>>
>>>> +                     }
>>>>                } 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;
>>
>>
>> This -ENOMEM does not roll back anything here.
>>
>> As stated above, dma_free_coherent() is called.
>> The problem is, ltq_etop_hw_exit() rolls back too much.
>>
>> If your requirement is "this driver is completely wrong. Please rewrite it",
>> sorry, I cannot (unless I am paid to do so).
>>
>> I am just following this driver's roll-back model.
>>
>> Please do not expect more to a person who
>> volunteers to eliminate build warnings.
>>
>> Of course, if somebody volunteers to rewrite this driver correctly,
>> that is appreciated.
> 
> Hi Hauke
> 
> Do you still have this hardware? Do you have time to take a look at
> the cleanup code?
> 
> Thanks
> 	Andrew
> 

Hi Andrew,

I have this hardware somewhere at home, but I never made it work.
If I find some time I can have a loom at this problem in the next few weeks.

Hauke
diff mbox series

Patch

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;
+			}
 		} 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;
+			}
 		}
 		ch->dma.irq = irq;
 	}