All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernardo Innocenti <bernie@develer.com>
To: akpm@zip.com.au
Cc: jgarzik@pobox.com, alan@redhat.com, linux-net@vger.kernel.org,
	linux-kernel@vger.kernel.org, aleph@develer.com
Subject: PATCH: fix bug in drivers/net/cs89x0.c:set_mac_address()
Date: Thu, 15 May 2003 03:23:14 +0200	[thread overview]
Message-ID: <3EC2EC02.7050608@develer.com> (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 <aleph@develer.com>.


--- linux-2.4.20.orig/drivers/net/cs89x0.c	2002-08-03 02:39:44.000000000 +0200
+++ linux-2.4.20/drivers/net/cs89x0.c	2003-01-18 19:00:37.000000000 +0100
@@ -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 */


-- 
  // 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


             reply	other threads:[~2003-05-15  1:10 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-15  1:23 Bernardo Innocenti [this message]
2003-05-20 17:24 ` PATCH: fix bug in drivers/net/cs89x0.c:set_mac_address() Alan Cox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3EC2EC02.7050608@develer.com \
    --to=bernie@develer.com \
    --cc=akpm@zip.com.au \
    --cc=alan@redhat.com \
    --cc=aleph@develer.com \
    --cc=jgarzik@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-net@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.