netdev
[Top] [All Lists]

Re: Question on net_device->refcnt && unregister_netdevice.

To: kuznet@xxxxxxxxxxxxx
Subject: Re: Question on net_device->refcnt && unregister_netdevice.
From: Ben Greear <greearb@xxxxxxxxxxxxxxx>
Date: Sun, 13 Feb 2000 12:12:28 -0700
Cc: netdev@xxxxxxxxxxx
Organization: Candela Technologies
References: <200002131637.TAA21062@ms2.inr.ac.ru>
Sender: owner-netdev@xxxxxxxxxxx
kuznet@xxxxxxxxxxxxx wrote:
> 
> Hello!
> 
> > unregister_netdevice:  Old style device vlan0004 leaked(refcnt=1).  Wait 
> > for crash.
> > (I especially like the last part!!)
> 
> It does not lie. If that guy who holds refcnt will remember about this
> device finally, it will be oops in the best case or even memory corruption.

I think I found most of them.  The problem was that I found devices
by their name quite often:  dev_get_by_name(), and never explicitly
released them.

Does this also cause problems in the 2.2 kernels?

> 
> If you allocate device struct via kmalloc(), it is better to convert
> it to "new style". F.e. look into tunnels or to ppp.

I'll do that...

> > Is this problem something that my code could be responsible for,
> > or is it something else in the stack?
> 
> It can be everywhere, where the device is referenced. Debug!

I think we should put some comments in the net_device struct to
explain what kinds of calls increment/decrement the refcnt.  I
eventually figured out it was the dev_put/dev_get* methods, but
only lots of poking and grepping yielded that...

Ben

-- 
Ben Greear (greearb@xxxxxxxxxxxxxxx)  http://scry.wanfear.com/~greear 
Author of ScryMUD:  scry.wanfear.com 4444        (Released under GPL)
http://scry.wanfear.com

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