netdev
[Top] [All Lists]

dev->destructor

To: shemminger@xxxxxxxx
Subject: dev->destructor
From: "David S. Miller" <davem@xxxxxxxxxx>
Date: Tue, 29 Apr 2003 23:26:31 -0700 (PDT)
Cc: netdev@xxxxxxxxxxx, kuznet@xxxxxxxxxxxxx
Sender: netdev-bounce@xxxxxxxxxxx
Stephen, you're right about the dev->destructor problem.
I misread your postings, and I'm very sorry about that.
We were talking about two different things, and admittedly
I had forgotten how some of this stuff works.

Alexey, currently dev->{open,close} are what does get/put
of device module reference.

However, device unregister can explode if dev->destructor is
present.  Unlike in dev->destructor==NULL case, we do not
wait for remnant dev->refcnt to go away.  Therefore we could
invoke dev->destructor() after module is unloaded.

I guess there are two ways to address this problem:

1) dev_get() gets module reference and dev_put() puts is.
   Ugly, as this means dev_get() can fail, but this does
   cover all the possible cases.

2) Make unregister_netdev() wait for refcount to reach 1
   regardless of whether dev->destructor is NULL or not.

I don't like #1.  Do you see some holes in #2?

As Stephen brought up, this also means we should do something
about that NETDEV_UNREGISTER code in dst_dev_event() :-(

<Prev in Thread] Current Thread [Next in Thread>