All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Fainelli <florian@openwrt.org>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: Julia Lawall <julia@diku.dk>, David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org
Subject: Re: question about drivers/net/cpmac.c
Date: Sun, 13 Dec 2009 13:19:51 +0100	[thread overview]
Message-ID: <200912131319.59229.florian@openwrt.org> (raw)
In-Reply-To: <1260705119.4532.609.camel@localhost>

Le dimanche 13 décembre 2009 12:51:59, Ben Hutchings a écrit :
> On Sun, 2009-12-13 at 12:00 +0100, Julia Lawall wrote:
> > On Sun, 13 Dec 2009, David Miller wrote:
> > > From: Julia Lawall <julia@diku.dk>
> > > Date: Sun, 13 Dec 2009 11:22:54 +0100 (CET)
> > >
> > > > The function __devinit cpmac_probe in the file drivers/net/cpmac.c
> > > > contains the following code:
> > > >
> > > > memcpy(dev->dev_addr, pdata->dev_addr, sizeof(dev->dev_addr));
> > > >
> > > > Is it correct that the size of the pointer is what is wanted?
> > >
> > > Everything that does sizeof(netdev->dev_addr) is a bug.
> > >
> > > At some point we changed netdev->dev_addr from an array of chars to a
> > > pointer to a dynamically allocated buffer.
> > >
> > > So these cases worked before that change and need to be updated
> > > in order to be correct.
> > >
> > > Looking quickly there are a couple of these things under
> > > drivers/net
> >
> > Fixed how?  I looked a bit to find where the field was initialized, but
> > it is just initialized to a field of something else, so it was not so
> > clear what the size should be.
> 
> [...]
> 
> The size should be dev->addr_len (assuming that has already been
> initialised) which will be ETH_ALEN for Ethernet devices.

From arch/mips/include/asm/mach-ar7/ar7.h:

struct plat_cpmac_data {
[..]
        char dev_addr[6];
};

So this should be fine to either use ETH_ALEN or sizeof(pdata->dev_addr).
-- 
Best regards, Florian Fainelli
Email: florian@openwrt.org
Web: http://openwrt.org
IRC: [florian] on irc.freenode.net
-------------------------------

  reply	other threads:[~2009-12-13 12:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-13 10:22 question about drivers/net/cpmac.c Julia Lawall
2009-12-13 10:25 ` question about drivers/net/3c507.c Julia Lawall
2009-12-13 10:40   ` David Miller
2009-12-13 10:39 ` question about drivers/net/cpmac.c David Miller
2009-12-13 11:00   ` Julia Lawall
2009-12-13 11:51     ` Ben Hutchings
2009-12-13 12:19       ` Florian Fainelli [this message]
2009-12-13 12:43         ` Julia Lawall

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=200912131319.59229.florian@openwrt.org \
    --to=florian@openwrt.org \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=julia@diku.dk \
    --cc=netdev@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.