lkml.org 
[lkml]   [2009]   [Aug]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] net: Fix spinlock use in alloc_netdev_mq()
    On Wed, 5 Aug 2009 10:47:47 +0200 Jiri Pirko <jpirko@redhat.com> wrote:

    > >it's using an zero-initialized spinlock. This is a side-effect of:
    > >
    > > dev_unicast_init(dev);
    > >
    > >in alloc_netdev_mq() making use of dev->addr_list_lock.
    > >
    > >The device has just been allocated freshly, it's not accessible
    > >anywhere yet so no locking is needed at all - in fact it's wrong
    > >to lock it here (the lock isnt initialized yet).
    >
    > Yes this looks like the right approach. Sorry for this bug :(

    Really?

    > >--- a/net/core/dev.c
    > >+++ b/net/core/dev.c
    > >@@ -4007,9 +4007,7 @@ static void dev_unicast_flush(struct net_device *dev)
    > >
    > > static void dev_unicast_init(struct net_device *dev)
    > > {
    > >- netif_addr_lock_bh(dev);
    > > __hw_addr_init(&dev->uc);
    > >- netif_addr_unlock_bh(dev);
    > > }

    This means that the net_device is still floating around for quite a
    long time with an uninitialised spinlock, so it will be quite easy for
    the same problem to reoccur as the code evolves.

    It would be more robust were we to initialise that lock close to the
    netdev's allocation site.



    \
     
     \ /
      Last update: 2009-08-05 19:17    [W:3.354 / U:0.104 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site