* dev_get_by_name without dev_put
@ 2001-07-04 13:49 fabrizio.gennari
2001-07-04 14:06 ` [PATCH] " Arnaldo Carvalho de Melo
2001-07-10 0:36 ` David S. Miller
0 siblings, 2 replies; 3+ messages in thread
From: fabrizio.gennari @ 2001-07-04 13:49 UTC (permalink / raw)
To: linux-kernel
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 fabrizio.gennari@philips.com
20052 Monza (MI) Italy http://www.research.philips.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] Re: dev_get_by_name without dev_put
2001-07-04 13:49 dev_get_by_name without dev_put fabrizio.gennari
@ 2001-07-04 14:06 ` Arnaldo Carvalho de Melo
2001-07-10 0:36 ` David S. Miller
1 sibling, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2001-07-04 14:06 UTC (permalink / raw)
To: fabrizio.gennari; +Cc: linux-kernel
Em Wed, Jul 04, 2001 at 03:49:46PM +0200, fabrizio.gennari@philips.com 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Re: dev_get_by_name without dev_put
2001-07-04 13:49 dev_get_by_name without dev_put fabrizio.gennari
2001-07-04 14:06 ` [PATCH] " Arnaldo Carvalho de Melo
@ 2001-07-10 0:36 ` David S. Miller
1 sibling, 0 replies; 3+ messages in thread
From: David S. Miller @ 2001-07-10 0:36 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: fabrizio.gennari, linux-kernel
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
davem@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-07-10 0:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-04 13:49 dev_get_by_name without dev_put fabrizio.gennari
2001-07-04 14:06 ` [PATCH] " Arnaldo Carvalho de Melo
2001-07-10 0:36 ` David S. Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).