diff mbox series

bcmgenet: add WOL IRQ check

Message ID 2b49e965-850c-9f71-cd54-6ca9b7571cc3@omp.ru (mailing list archive)
State Accepted
Commit 9deb48b53e7f4056c2eaa2dc2ee3338df619e4f6
Delegated to: Netdev Maintainers
Headers show
Series bcmgenet: add WOL IRQ check | expand

Checks

Context Check Description
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 2 this patch: 2
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Sergey Shtylyov Jan. 13, 2022, 7:46 p.m. UTC
The driver neglects to check the result of platform_get_irq_optional()'s
call and blithely passes the negative error codes to devm_request_irq()
(which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
Stop calling devm_request_irq() with the invalid IRQ #s.

Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>

---
This patch is against DaveM's 'net.git' repo.

 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Andrew Lunn Jan. 13, 2022, 9 p.m. UTC | #1
On Thu, Jan 13, 2022 at 10:46:07PM +0300, Sergey Shtylyov wrote:
> The driver neglects to check the result of platform_get_irq_optional()'s
> call and blithely passes the negative error codes to devm_request_irq()
> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
> Stop calling devm_request_irq() with the invalid IRQ #s.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> ---
> This patch is against DaveM's 'net.git' repo.

Since this is for net, it needs a Fixes: tag.

Fixes: 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

       Andrew
Florian Fainelli Jan. 13, 2022, 9:37 p.m. UTC | #2
On 1/13/2022 1:00 PM, Andrew Lunn wrote:
> On Thu, Jan 13, 2022 at 10:46:07PM +0300, Sergey Shtylyov wrote:
>> The driver neglects to check the result of platform_get_irq_optional()'s
>> call and blithely passes the negative error codes to devm_request_irq()
>> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
>> Stop calling devm_request_irq() with the invalid IRQ #s.
>>
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>
>> ---
>> This patch is against DaveM's 'net.git' repo.
> 
> Since this is for net, it needs a Fixes: tag.
> 
> Fixes: 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

I don't have strong objections whether we want to consider this a bug 
fix or not, but since the code only acts upon devm_request_irq() 
returning 0 meaning success, this seems more like an improvement rather 
than fixing an actual issue.
Florian Fainelli Jan. 13, 2022, 9:47 p.m. UTC | #3
On 1/13/2022 1:37 PM, Florian Fainelli wrote:
> 
> 
> On 1/13/2022 1:00 PM, Andrew Lunn wrote:
>> On Thu, Jan 13, 2022 at 10:46:07PM +0300, Sergey Shtylyov wrote:
>>> The driver neglects to check the result of platform_get_irq_optional()'s
>>> call and blithely passes the negative error codes to devm_request_irq()
>>> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
>>> Stop calling devm_request_irq() with the invalid IRQ #s.
>>>
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>>
>>> ---
>>> This patch is against DaveM's 'net.git' repo.
>>
>> Since this is for net, it needs a Fixes: tag.
>>
>> Fixes: 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")
> 
> I don't have strong objections whether we want to consider this a bug 
> fix or not, but since the code only acts upon devm_request_irq() 
> returning 0 meaning success, this seems more like an improvement rather 
> than fixing an actual issue.

If you do repost, please subject your patch with "net: bcmgenet" for 
consistency with previous commits done to that file, and feel free to add:

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Sergey Shtylyov Jan. 14, 2022, 10:58 a.m. UTC | #4
Hello!

On 1/14/22 12:37 AM, Florian Fainelli wrote:

>>> The driver neglects to check the result of platform_get_irq_optional()'s
>>> call and blithely passes the negative error codes to devm_request_irq()
>>> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
>>> Stop calling devm_request_irq() with the invalid IRQ #s.
>>>
>>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>>
>>> ---
>>> This patch is against DaveM's 'net.git' repo.
>>
>> Since this is for net, it needs a Fixes: tag.
>>
>> Fixes: 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")
> 
> I don't have strong objections whether we want to consider this a bug fix or not,

   Formally, it's a fix -- as you shouldn't call devm_request_irq() with "negative" IRQ #s.

> but since the code only acts upon devm_request_irq() returning 0 meaning success, this seems more like an improvement rather than fixing an actual issue.

   More like a cleanup (no, not improvement).

MBR, Sergey
Sergey Shtylyov Jan. 14, 2022, 11:03 a.m. UTC | #5
Hello!

On 1/14/22 12:00 AM, Andrew Lunn wrote:

>> The driver neglects to check the result of platform_get_irq_optional()'s
>> call and blithely passes the negative error codes to devm_request_irq()
>> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
>> Stop calling devm_request_irq() with the invalid IRQ #s.
>>
>> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
>>
>> ---
>> This patch is against DaveM's 'net.git' repo.
> 
> Since this is for net, it needs a Fixes: tag.
> 
> Fixes: 8562056f267d ("net: bcmgenet: request Wake-on-LAN interrupt")

   Indeed, I completely forgot about it. Thanks! :-)

>        Andrew

MBR, Sergey
patchwork-bot+netdevbpf@kernel.org Jan. 14, 2022, 11:30 a.m. UTC | #6
Hello:

This patch was applied to netdev/net.git (master)
by David S. Miller <davem@davemloft.net>:

On Thu, 13 Jan 2022 22:46:07 +0300 you wrote:
> The driver neglects to check the result of platform_get_irq_optional()'s
> call and blithely passes the negative error codes to devm_request_irq()
> (which takes *unsigned* IRQ #), causing it to fail with -EINVAL.
> Stop calling devm_request_irq() with the invalid IRQ #s.
> 
> Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru>
> 
> [...]

Here is the summary with links:
  - bcmgenet: add WOL IRQ check
    https://git.kernel.org/netdev/net/c/9deb48b53e7f

You are awesome, thank you!
diff mbox series

Patch

Index: net/drivers/net/ethernet/broadcom/genet/bcmgenet.c
===================================================================
--- net.orig/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ net/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -4020,10 +4020,12 @@  static int bcmgenet_probe(struct platfor
 
 	/* Request the WOL interrupt and advertise suspend if available */
 	priv->wol_irq_disabled = true;
-	err = devm_request_irq(&pdev->dev, priv->wol_irq, bcmgenet_wol_isr, 0,
-			       dev->name, priv);
-	if (!err)
-		device_set_wakeup_capable(&pdev->dev, 1);
+	if (priv->wol_irq > 0) {
+		err = devm_request_irq(&pdev->dev, priv->wol_irq,
+				       bcmgenet_wol_isr, 0, dev->name, priv);
+		if (!err)
+			device_set_wakeup_capable(&pdev->dev, 1);
+	}
 
 	/* Set the needed headroom to account for any possible
 	 * features enabling/disabling at runtime