Re: [patch] 2.3.99-pre3-3: dev_alloc_name

From: Nick Holloway (Nick.Holloway@alfie.demon.co.uk)
Date: Wed Mar 22 2000 - 03:41:31 EST


twaugh@redhat.com (Tim Waugh) writes:
> On Tue, 21 Mar 2000, Andrew Morton wrote:
> > char s[16];
> > int i;
> >
> > and the strings are separated and placed in .data, just as we want.
>
> No, I thought of that. Check how many times dev->name is assigned to in
> drivers/net/*.c -- it's scary.

All of the assignments are there because of the need to allocate the
memory for dev->name.

They fall into three patterns:

    * Have a static char array ("namelist" or "ifnames"), and set
      dev->name to point into offsets within it.
    * Have a char[] array in the private device structure, and set
      dev->name to point to vp->devname.
    * Over-allocate bytes at the end of the netdevice structure, and set
      dev->name to point to these extra bytes.

It wouldn't be that difficult (just tedious) to change the 27 files to
cope with this. However, before it was started, I think waiting until
this approach gets the nod from someone with the influence to get the
patch accepted would be prudent. Alan?

Alexey wrote:
> Not strdup. Device name _MUST_ have IFNAMSIZ writable bytes.

This comments means that all apart from 4 would need changing anyway.
The majority only allocate 8 or 9 bytes for dev->name. Only wavelan,
depca, ppp_generic and net_init allocate 16. Of these, only wavelan
and net_init actually use the IFNAMSIZ size.

I think it would be better to byte the bullet and change "dev->name"
from "char*" to "char[IFNAMSIZ]" and fix the net drivers properly,
rather than fix the allocated size of "dev->name" in the majority.

I think the alternative of setting -fwritable_strings for one source
file is going to be merely a bandaid.

I'm willing to have a stab at putting a patch together, but I would need
some assistance in checking the results actually worked.

-- 
 `O O'  | Nick.Holloway@alfie.demon.co.uk
// ^ \\ | http://www.alfie.demon.co.uk/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:35 EST