Every time dev_get_by_name is called, and it has returned a valid struct net_device*, dev_put should be called afterwards, because otherwise the machine hangs when the device is unregistered (since dev->refcnt > 1). However, it seems that some drivers do
not call dev_put after dev_get_by_name: for example, drivers/net/pppoe.c at line 573 and net/core/dv.c at line 168. Am I wrong?
---------------------------------------------------------
Fabrizio Gennari tel. +39 039 203 7816
Philips Research Monza fax. +39 039 203 7800
via G. Casati 23 [email protected]
20052 Monza (MI) Italy http://www.research.philips.com
Em Wed, Jul 04, 2001 at 03:49:46PM +0200, [email protected] escreveu:
> Every time dev_get_by_name is called, and it has returned a valid struct net_device*, dev_put should be called afterwards, because otherwise the machine hangs when the device is unregistered (since dev->refcnt > 1). However, it seems that some drivers do
> not call dev_put after dev_get_by_name: for example, drivers/net/pppoe.c at line 573 and net/core/dv.c at line 168. Am I wrong?
For pppoe (and one has to look at the set_item and see if delete_item is
needed).
- Arnaldo
--- linux-2.4.5-ac24/drivers/net/pppoe.c Tue Jul 3 18:45:41 2001
+++ linux-2.4.5-ac24.acme/drivers/net/pppoe.c Wed Jul 4 11:00:47 2001
@@ -567,17 +567,17 @@
if (!dev)
goto end;
+ po->pppoe_dev = dev;
+
if( ! (dev->flags & IFF_UP) )
- goto end;
+ goto err_put;
memcpy(&po->pppoe_pa,
&sp->sa_addr.pppoe,
sizeof(struct pppoe_addr));
error = set_item(po);
if (error < 0)
- goto end;
-
- po->pppoe_dev = dev;
+ goto err_put;
po->chan.hdrlen = (sizeof(struct pppoe_hdr) +
dev->hard_header_len);
@@ -586,6 +586,8 @@
po->chan.ops = &pppoe_chan_ops;
error = ppp_register_channel(&po->chan);
+ if (error)
+ goto err_put;
sk->state = PPPOX_CONNECTED;
}
@@ -595,6 +597,10 @@
end:
release_sock(sk);
return error;
+err_put:
+ dev_put(po->pppoe_dev);
+ po->pppoe_dev = NULL;
+ goto end;
}
- Arnaldo
Arnaldo Carvalho de Melo writes:
> For pppoe (and one has to look at the set_item and see if delete_item is
> needed).
Applied, sorry for taking so long.
Later,
David S. Miller
[email protected]