Skip to contentSkip to conversation

3c507.c: remove unused NULL pointer check

PATCH In review Alexander Strakh 3 participants 4 messages Dec 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 3c507.c: remove unused NULL pointer check

In driver drivers/net/3c507.c in function Iirqreturn_t el16_interrupt:
1. If in line 555 dev = NULL then we goto line 556
2. In line 556 we have null dereference because pr_err called with dev->name in third parameter.
555 if (dev == NULL) {
556 pr_err("%s: net_interrupt(): irq %d for unknown device.
\n",
557 dev->name, irq);
558 return IRQ_NONE;
559 }

Found by Linux Device Drivers Verification (Svace detector)

Remove unused NULL pointer check.

---

./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -6
index fbc2311..3bfb3dd 100644
@@ -552,12 +552,6 @@ static irqreturn_t el16_interrupt(int irq, void *dev_id)
 	ushort ack_cmd = 0;
 	void __iomem *shmem;
 
-	if (dev == NULL) {
-		pr_err("%s: net_interrupt(): irq %d for unknown device.\n",
-			dev->name, irq);
-		return IRQ_NONE;
-	}
-
 	ioaddr = dev->base_addr;
 	lp = netdev_priv(dev);
 	shmem = lp->base;
#1 lore raw
Quoted 11 lines · Alexander Strakh

In driver drivers/net/3c507.c in function Iirqreturn_t el16_interrupt:
1. If in line 555 dev = NULL then we goto line 556
2. In line 556 we have null dereference because pr_err called with dev->name in third parameter.
555 if (dev == NULL) {
556 pr_err("%s: net_interrupt(): irq %d for unknown device.
\n",
557 dev->name, irq);
558 return IRQ_NONE;
559 }

Quoted 3 lines

Found by Linux Device Drivers Verification (Svace detector)

Remove unused NULL pointer check.

You are obviously doing more than that ...

Quoted 9 lines

---

./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -0
index fbc2311..3bfb3dd 100644

./moder/drivers/net/3c507.c static irqreturn_t el16_interrupt(int irq, void *dev_id) · line 557

Quoted 6 lines
./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -3
@@ -552,12 +552,6 @@ static irqreturn_t el16_interrupt(int irq, void *dev_id)
 	ushort ack_cmd = 0;
 	void __iomem *shmem;
 
-	if (dev == NULL) {
-		pr_err("%s: net_interrupt(): irq %d for unknown device.\n",
-			dev->name, irq);

You are changing real funcionality here!

If you want to fix it, fix the pr_err() but do not remove the "return IRQ_NONE" entirely.

This looks like an introduction of a bug.

Regards,
Oliver

Quoted 3 lines
./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -3
-		return IRQ_NONE;
-	}
-
#2 lore raw
Quoted 41 lines · On Mon, 21 Dec 2009 17:56:39 +0100 Oliver Hartkopp <[email protected]>…
Quoted 11 lines · Alexander Strakh

In driver drivers/net/3c507.c in function Iirqreturn_t el16_interrupt:
1. If in line 555 dev = NULL then we goto line 556
2. In line 556 we have null dereference because pr_err called with dev->name in third parameter.
555 if (dev == NULL) {
556 pr_err("%s: net_interrupt(): irq %d for unknown device.
\n",
557 dev->name, irq);
558 return IRQ_NONE;
559 }

Quoted 3 lines

Found by Linux Device Drivers Verification (Svace detector)

Remove unused NULL pointer check.

You are obviously doing more than that ...

Quoted 9 lines

---

./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -0
index fbc2311..3bfb3dd 100644

./moder/drivers/net/3c507.c static irqreturn_t el16_interrupt(int irq, void *dev_id) · line 557

Quoted 6 lines
./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -3
@@ -552,12 +552,6 @@ static irqreturn_t el16_interrupt(int irq, void *dev_id)
 	ushort ack_cmd = 0;
 	void __iomem *shmem;
 
-	if (dev == NULL) {
-		pr_err("%s: net_interrupt(): irq %d for unknown device.\n",
-			dev->name, irq);

You are changing real funcionality here!

If you want to fix it, fix the pr_err() but do not remove the "return IRQ_NONE" entirely.

This looks like an introduction of a bug.

Quoted 7 lines

Regards,
Oliver

./moder/drivers/net/3c507.c static irqreturn_t el16_interrupt(int irq, void *dev_id) · line 560

Quoted 3 lines
./moder/drivers/net/3c507.c renamed from ./0000/drivers/net/3c507.c +0 -3
-		return IRQ_NONE;
-	}
-

Interrupts will never be called with third parameter of NULL. It is really bogus impossible to reach code.

#3 lore raw
Quoted 15 lines · Stephen Hemminger
Quoted 12 lines · On Mon, 21 Dec 2009 17:56:39 +0100 Oliver Hartkopp <[email protected]>…
Quoted 11 lines · Alexander Strakh

In driver drivers/net/3c507.c in function Iirqreturn_t el16_interrupt:
1. If in line 555 dev = NULL then we goto line 556
2. In line 556 we have null dereference because pr_err called with dev->name in third parameter.
555 if (dev == NULL) {
556 pr_err("%s: net_interrupt(): irq %d for unknown device.
\n",
557 dev->name, irq);
558 return IRQ_NONE;
559 }

Quoted 8 lines
Quoted 3 lines
Quoted 3 lines

Found by Linux Device Drivers Verification (Svace detector)

Remove unused NULL pointer check.

Interrupts will never be called with third parameter of NULL. It is really bogus impossible to reach code.

You're right! I just did not verify the direct assignment of dev = dev_id ...

Btw. the description for the reason of this patch remains unsuitably as the problem is not the potential dereferencing of dev->name in pr_err() here.

It should better be something like this (partly stolen from your answer):

Interrupts will never be called with dev_id parameter of NULL. This patch removes the obsolete, unreachable code.

Regards,
Oliver