All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] stmmac: fix pointer check after utilization in stmmac_interrupt
@ 2020-05-04 15:42 Markus Elfring
  0 siblings, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2020-05-04 15:42 UTC (permalink / raw)
  To: Maxim Petrov, netdev
  Cc: linux-kernel, Alexandre Torgue, David S. Miller,
	Giuseppe Cavallaro, Jose Abreu, Maxime Coquelin

> … However, the code fragment is incorrect
> because the dev pointer is used before the actual check

I find such information interesting.


> which leads to undefined behavior. …

I suggest to adjust the wording for this “conclusion”.

Regards,
Markus

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] stmmac: fix pointer check after utilization in stmmac_interrupt
  2020-05-04  6:26 Maxim Petrov
@ 2020-05-04 17:34 ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2020-05-04 17:34 UTC (permalink / raw)
  To: mmrmaximuzz
  Cc: peppe.cavallaro, alexandre.torgue, joabreu, mcoquelin.stm32,
	netdev, linux-kernel

From: Maxim Petrov <mmrmaximuzz@gmail.com>
Date: Mon, 4 May 2020 09:26:43 +0300

> The paranoidal pointer check in IRQ handler looks very strange - it
> really protects us only against bogus drivers which request IRQ line
> with null pointer dev_id. However, the code fragment is incorrect
> because the dev pointer is used before the actual check which leads
> to undefined behavior. Remove the check to avoid confusing people
> with incorrect code.
> 
> Signed-off-by: Maxim Petrov <mmrmaximuzz@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2] stmmac: fix pointer check after utilization in stmmac_interrupt
@ 2020-05-04  6:26 Maxim Petrov
  2020-05-04 17:34 ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Maxim Petrov @ 2020-05-04  6:26 UTC (permalink / raw)
  To: Giuseppe Cavallaro, Alexandre Torgue, Jose Abreu,
	David S. Miller, Maxime Coquelin
  Cc: mmrmaximuzz, netdev, linux-kernel

The paranoidal pointer check in IRQ handler looks very strange - it
really protects us only against bogus drivers which request IRQ line
with null pointer dev_id. However, the code fragment is incorrect
because the dev pointer is used before the actual check which leads
to undefined behavior. Remove the check to avoid confusing people
with incorrect code.

Signed-off-by: Maxim Petrov <mmrmaximuzz@gmail.com>
---
Changes in V2:
* Remove the incorrect check instead of fixing it (suggested by
  David Miller)
* Add clarification to the function description

 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 565da6498c84..e2b095d936cf 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -4060,7 +4060,7 @@ static int stmmac_set_features(struct net_device *netdev,
 /**
  *  stmmac_interrupt - main ISR
  *  @irq: interrupt number.
- *  @dev_id: to pass the net device pointer.
+ *  @dev_id: to pass the net device pointer (must be valid).
  *  Description: this is the main driver interrupt service routine.
  *  It can call:
  *  o DMA service routine (to manage incoming frame reception and transmission
@@ -4084,11 +4084,6 @@ static irqreturn_t stmmac_interrupt(int irq, void *dev_id)
 	if (priv->irq_wake)
 		pm_wakeup_event(priv->device, 0);
 
-	if (unlikely(!dev)) {
-		netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__);
-		return IRQ_NONE;
-	}
-
 	/* Check if adapter is up */
 	if (test_bit(STMMAC_DOWN, &priv->state))
 		return IRQ_HANDLED;

base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-04 17:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-04 15:42 [PATCH v2] stmmac: fix pointer check after utilization in stmmac_interrupt Markus Elfring
  -- strict thread matches above, loose matches on Subject: below --
2020-05-04  6:26 Maxim Petrov
2020-05-04 17:34 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.