Skip to contentSkip to conversation

PATCH: fix bug in drivers/net/cs89x0.c:set_mac_address()

PATCH Applied Bernardo Innocenti 2 participants 2 messages May 15, 2003 – May 20, 2003 Network drivers

lore
Share & tools
lore
#0 lore raw

Hello Andrew, Jeff and Alan,

the following patch fixes a bug in the CS89xx net device which would set new MAC address through SIOCSIFHWADDR _only_ when net_debug is set, which is obviously not what it was meant to do. The original code bogusly interpreted the addr argument as a buffer containing the MAC address instead of a struct sockaddr.

Applies as-is to 2.4.20 and with offset to 2.5.69. Please forward it to Linus and Marcelo. This bug has been found and fixed by Stefano Fedrigo <[email protected]>.

drivers/net/cs89x0.c +0 -0
@@ -1629,16 +1629,21 @@

}

-static int set_mac_address(struct net_device *dev, void *addr) +static int set_mac_address(struct net_device *dev, void *p)

{
	int i;

+ struct sockaddr *addr = p;
+

	if (netif_running(dev))
		return -EBUSY;
+
+	memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
+
	if (net_debug) {
		printk("%s: Setting MAC address to ", dev->name);
-		for (i = 0; i < 6; i++)
-			printk(" %2.2x", dev->dev_addr[i] = ((unsigned char *)addr)[i]);
+		for (i = 0; i < dev->addr_len; i++)
+			printk(" %2.2x", dev->dev_addr[i]);
		printk(".\n");
	}
	/* set the Ethernet address */
Signature · 5 lines
 // Bernardo Innocenti - Develer S.r.l., R&D dept.
\X/  http://www.develer.com/

Please don't send Word attachments.
See: http://www.gnu.org/philosophy/no-word-attachments.html
Applied
#1 lore raw
Quoted 1 line · Bernardo Innocenti

Hello Andrew, Jeff and Alan,

Applied to -ac - thanks