public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong
@ 2005-03-22 22:05 Adrian Bunk
  2005-03-22 22:17 ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2005-03-22 22:05 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-net, linux-kernel

if
Reply-To: 

The Coverity checker correctly noted that this condition can't ever be 
fulfilled.

Can someone understanding this code check whether my guess what this 
should have been was right?

Or should the if get completely dropped?

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c.old	2005-03-22 21:41:37.000000000 +0100
+++ linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c	2005-03-22 21:42:01.000000000 +0100
@@ -3440,9 +3440,6 @@
 	/* Make sure we got something */
 	if (rxd.rdy && rxd.valid == 0) {
 		len = rxd.len + 12;
-		if (len < 12 && len > 2048)
-			goto badrx;
-
 		skb = dev_alloc_skb(len);
 		if (!skb) {
 			ai->stats.rx_dropped++;


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

* Re: [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong
  2005-03-22 22:05 [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong Adrian Bunk
@ 2005-03-22 22:17 ` Jeff Garzik
  2005-03-22 22:30   ` Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2005-03-22 22:17 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-net, linux-kernel

Adrian Bunk wrote:
> if
> Reply-To: 
> 
> The Coverity checker correctly noted that this condition can't ever be 
> fulfilled.
> 
> Can someone understanding this code check whether my guess what this 
> should have been was right?
> 
> Or should the if get completely dropped?
> 
> Signed-off-by: Adrian Bunk <bunk@stusta.de>
> 
> --- linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c.old	2005-03-22 21:41:37.000000000 +0100
> +++ linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c	2005-03-22 21:42:01.000000000 +0100
> @@ -3440,9 +3440,6 @@
>  	/* Make sure we got something */
>  	if (rxd.rdy && rxd.valid == 0) {
>  		len = rxd.len + 12;
> -		if (len < 12 && len > 2048)
> -			goto badrx;

Coverity is silly.

len is signed, and so can obviously be less than zero in edge cases.  I 
don't see where the "> 2048" test is invalid, either.

	Jeff




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

* Re: [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong
  2005-03-22 22:17 ` Jeff Garzik
@ 2005-03-22 22:30   ` Adrian Bunk
  2005-03-22 22:34     ` Jeff Garzik
  0 siblings, 1 reply; 5+ messages in thread
From: Adrian Bunk @ 2005-03-22 22:30 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-net, linux-kernel

On Tue, Mar 22, 2005 at 05:17:21PM -0500, Jeff Garzik wrote:
> Adrian Bunk wrote:
> >if
> >Reply-To: 
> >
> >The Coverity checker correctly noted that this condition can't ever be 
> >fulfilled.
> >
> >Can someone understanding this code check whether my guess what this 
> >should have been was right?
> >
> >Or should the if get completely dropped?
> >
> >Signed-off-by: Adrian Bunk <bunk@stusta.de>
> >
> >--- linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c.old	2005-03-22 
> >21:41:37.000000000 +0100
> >+++ linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c	2005-03-22 
> >21:42:01.000000000 +0100
> >@@ -3440,9 +3440,6 @@
> > 	/* Make sure we got something */
> > 	if (rxd.rdy && rxd.valid == 0) {
> > 		len = rxd.len + 12;
> >-		if (len < 12 && len > 2048)
> >-			goto badrx;
> 
> Coverity is silly.
> 
> len is signed, and so can obviously be less than zero in edge cases.  I 
> don't see where the "> 2048" test is invalid, either.

But if it's less than zero it can't be > 2048 at the same time?

The point is: len can't be both < 12 and > 2048 at the same time.


Is this "if" simply superfluous?
Or should the && be an || ?


> 	Jeff

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


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

* Re: [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong
  2005-03-22 22:30   ` Adrian Bunk
@ 2005-03-22 22:34     ` Jeff Garzik
  2005-03-25  0:15       ` [2.6 patch] drivers/net/wireless/airo.c: correct a wrong check Adrian Bunk
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Garzik @ 2005-03-22 22:34 UTC (permalink / raw)
  To: Adrian Bunk; +Cc: linux-net, linux-kernel

On Tue, Mar 22, 2005 at 11:30:56PM +0100, Adrian Bunk wrote:
> On Tue, Mar 22, 2005 at 05:17:21PM -0500, Jeff Garzik wrote:
> > Adrian Bunk wrote:
> > >if
> > >Reply-To: 
> > >
> > >The Coverity checker correctly noted that this condition can't ever be 
> > >fulfilled.
> > >
> > >Can someone understanding this code check whether my guess what this 
> > >should have been was right?
> > >
> > >Or should the if get completely dropped?
> > >
> > >Signed-off-by: Adrian Bunk <bunk@stusta.de>
> > >
> > >--- linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c.old	2005-03-22 
> > >21:41:37.000000000 +0100
> > >+++ linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c	2005-03-22 
> > >21:42:01.000000000 +0100
> > >@@ -3440,9 +3440,6 @@
> > > 	/* Make sure we got something */
> > > 	if (rxd.rdy && rxd.valid == 0) {
> > > 		len = rxd.len + 12;
> > >-		if (len < 12 && len > 2048)
> > >-			goto badrx;
> > 
> > Coverity is silly.
> > 
> > len is signed, and so can obviously be less than zero in edge cases.  I 
> > don't see where the "> 2048" test is invalid, either.
> 
> But if it's less than zero it can't be > 2048 at the same time?
> 
> The point is: len can't be both < 12 and > 2048 at the same time.
> 
> 
> Is this "if" simply superfluous?
> Or should the && be an || ?

Yes, it looks like it should be "||".

	Jeff




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

* [2.6 patch] drivers/net/wireless/airo.c: correct a wrong check
  2005-03-22 22:34     ` Jeff Garzik
@ 2005-03-25  0:15       ` Adrian Bunk
  0 siblings, 0 replies; 5+ messages in thread
From: Adrian Bunk @ 2005-03-25  0:15 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: linux-net, linux-kernel

On Tue, Mar 22, 2005 at 05:34:03PM -0500, Jeff Garzik wrote:
> On Tue, Mar 22, 2005 at 11:30:56PM +0100, Adrian Bunk wrote:
>...
> > Is this "if" simply superfluous?
> > Or should the && be an || ?
> 
> Yes, it looks like it should be "||".

Patch below.

> 	Jeff

cu
Adrian


<--  snip  -->


The Coverity checker correctly noted that this condition can't ever be 
fulfilled.

This patch changes it to what it should have been.

Signed-off-by: Adrian Bunk <bunk@stusta.de>

--- linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c.old	2005-03-22 21:41:37.000000000 +0100
+++ linux-2.6.12-rc1-mm1-full/drivers/net/wireless/airo.c	2005-03-22 22:50:03.000000000 +0100
@@ -3440,7 +3440,7 @@
 	/* Make sure we got something */
 	if (rxd.rdy && rxd.valid == 0) {
 		len = rxd.len + 12;
-		if (len < 12 && len > 2048)
+		if (len < 12 || len > 2048)
 			goto badrx;
 
 		skb = dev_alloc_skb(len);

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

end of thread, other threads:[~2005-03-25  1:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-03-22 22:05 [RFC: 2.6 patch] drivers/net/wireless/airo.c: correct a wrong Adrian Bunk
2005-03-22 22:17 ` Jeff Garzik
2005-03-22 22:30   ` Adrian Bunk
2005-03-22 22:34     ` Jeff Garzik
2005-03-25  0:15       ` [2.6 patch] drivers/net/wireless/airo.c: correct a wrong check Adrian Bunk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox