| To: | Maillist netdev <netdev@xxxxxxxxxxx> |
|---|---|
| Subject: | double-check me? |
| From: | Jeff Garzik <jgarzik@xxxxxxxxx> |
| Date: | Sun, 17 Aug 2003 13:45:52 -0400 |
| Cc: | "David S. Miller" <davem@xxxxxxxxxx> |
| Organization: | none |
| Sender: | netdev-bounce@xxxxxxxxxxx |
| User-agent: | Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20021213 Debian/1.2.1-2.bunk |
Maybe you guys can spot something I'm missing here. alloc_netdev is
supposed to guarantee that dev->priv is aligned by 32 bytes:
struct net_device *alloc_netdev(int sizeof_priv, const char *mask,
void (*setup)(struct net_device *))
{
struct net_device *dev;
int alloc_size;
/* ensure 32-byte alignment of the private area */
alloc_size = sizeof (*dev) + sizeof_priv + 31;
dev = (struct net_device *) kmalloc (alloc_size, GFP_KERNEL);
if (dev == NULL)
{
printk(KERN_ERR "alloc_dev: Unable to allocate device
memory.\n"
);
return NULL;
}
memset(dev, 0, alloc_size);
if (sizeof_priv)
dev->priv = (void *) (((long)(dev + 1) + 31) & ~31);
Now... shouldn't that last line of code be "dev + 1 + sizeof(*dev)" ?
It seems to work 2.[456] for a long time, so I am doubting myself...
surely it would have caused memory corruption or something by now if I
have really found a bug.
Jeff
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: [2.4 PATCH] bugfix: ARP respond on all devices, Alan Cox |
|---|---|
| Next by Date: | [bk patches] net driver updates, Jeff Garzik |
| Previous by Thread: | linux-2.4.21 and IPv6: problem solved, w.szukalski |
| Next by Thread: | Re: double-check me?, Krzysztof Halasa |
| Indexes: | [Date] [Thread] [Top] [All Lists] |