Skip to contentSkip to conversation

staging: ozwpan: fix memcmp() test in oz_set_active_pd()

PATCH In review Dan Carpenter 4 participants 5 messages Aug 18, 2012 – Aug 19, 2012

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

PATCH 1/1 staging: ozwpan: fix memcmp() test in oz_set_active_pd()

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want to compare 6 bytes (ETH_ALEN).

drivers/staging/ozwpan/ozcdev.c +1 -1
index d983219..63c1b67 100644
@@ -213,7 +213,7 @@ static int oz_set_active_pd(u8 *addr)
 		if (old_pd)
 			oz_pd_put(old_pd);
 	} else {
-		if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
+		if (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) {
 			spin_lock_bh(&g_cdev.lock);
 			pd = g_cdev.active_pd;
 			g_cdev.active_pd = 0;
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Dan Carpenter

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want to compare 6 bytes (ETH_ALEN).

Quoted 14 lines
drivers/staging/ozwpan/ozcdev.c +1 -1
index d983219..63c1b67 100644
@@ -213,7 +213,7 @@ static int oz_set_active_pd(u8 *addr)
  		if (old_pd)
  			oz_pd_put(old_pd);
  	} else {
-		if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
+		if (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) {
  			spin_lock_bh(&g_cdev.lock);
  			pd = g_cdev.active_pd;
  			g_cdev.active_pd = 0;
Signature · 2 lines
Regards,
Rupesh Gujare
#2 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Dan Carpenter
Quoted 5 lines

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want to compare 6 bytes (ETH_ALEN).

why not to use 'if (is_zero_ether_addr())" from linux/etherdevice.h Thanks
Tomas

Quoted 30 lines
Quoted 10 lines
drivers/staging/ozwpan/ozcdev.c +0 -0
index d983219..63c1b67 100644

drivers/staging/ozwpan/ozcdev.c static int oz_set_active_pd(u8 *addr) · line 219

Quoted 8 lines
drivers/staging/ozwpan/ozcdev.c +1 -1
@@ -213,7 +213,7 @@ static int oz_set_active_pd(u8 *addr)
                if (old_pd)
                        oz_pd_put(old_pd);
        } else {
-               if (!memcmp(addr, "\0\0\0\0\0\0", sizeof(addr))) {
+               if (!memcmp(addr, "\0\0\0\0\0\0", ETH_ALEN)) {
                        spin_lock_bh(&g_cdev.lock);
                        pd = g_cdev.active_pd;
                        g_cdev.active_pd = 0;

--
Regards,
Rupesh Gujare

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

#3 lore raw
In reply to Dan Carpenter
Quoted 9 lines · Tomas Winkler
Quoted 7 lines · Dan Carpenter
Quoted 4 lines

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want to compare 6 bytes (ETH_ALEN).

why not to use 'if (is_zero_ether_addr())" from linux/etherdevice.h

Tom,

Thanks for pointing this out, that looks more efficient. Interested in submitting a patch ?

Dan,

What do you think ?

Signature · 2 lines
Regards,
Rupesh Gujare
#4 lore raw
In reply to Dan Carpenter
Quoted 10 lines · Rupesh Gujare
Quoted 9 lines · Tomas Winkler
Quoted 7 lines · Dan Carpenter
Quoted 4 lines

"addr" is a pointer so it's either 4 or 8 bytes, but actually we want to compare 6 bytes (ETH_ALEN).

why not to use 'if (is_zero_ether_addr())" from linux/etherdevice.h

Quoted 9 lines

Tom,

Thanks for pointing this out, that looks more efficient. Interested in submitting a patch ?

Dan,

What do you think ?

Yes yes. Of course. It's the weekend and I'm traveling but I can redo this.

regards,
dan carpenter