All of lore.kernel.org
 help / color / mirror / Atom feed
From: DJBARROW@de.ibm.com
To: linux-kernel@vger.kernel.org
Subject: bug in /net/core/dev.c
Date: Mon, 11 Jun 2001 20:32:03 +0200	[thread overview]
Message-ID: <C1256A68.0065E17F.00@d12mta09.de.ibm.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]




Hi,
I found this bug in dev.c

It happens if register_netdevice is called before net_dev_init which can
happen from init functions,
when device drivers are compiled into the kernel.

The dev->refcnt will go up to 2 ( it should be 1) unregister_netdevice will
usually  loop forever
waiting for the refcnt to drop to 1 when an attempt to unregister is done.

The printk in the bootmessages early initialization of device <blah> is
deferred is evidence of this behaviour occuring.

The small patch is below ,hope it is okay for you.

(See attached file: dev.c.2.4.5.patch)

D.J. Barrow Gnu/Linux for S/390 kernel developer
eMail: djbarrow@de.ibm.com,barrow_dj@yahoo.com
Phone: +49-(0)7031-16-2583
IBM Germany Lab, Schönaicherstr. 220, 71032 Böblingen

[-- Attachment #2: dev.c.2.4.5.patch --]
[-- Type: application/octet-stream, Size: 900 bytes --]

--- net/core/dev.old.c	Mon Jun 11 20:00:42 2001
+++ net/core/dev.c	Mon Jun 11 19:51:55 2001
@@ -20,6 +20,9 @@
  *              Pekka Riikonen <priikone@poesidon.pspt.fi>
  *
  *	Changes:
+ *              D.J. Barrow     :       Fixed net_dev_init calling dev_hold & setting
+ *                                      The dev->refcnt to 2 if register_netdev gets 
+ *                                      called first & initialization is deferred.
  *		Alan Cox	:	device private ioctl copies fields back.
  *		Alan Cox	:	Transmit queue code does relevant stunts to
  *					keep the queue safe.
@@ -2733,8 +2736,10 @@
 #endif
 		dev->xmit_lock_owner = -1;
 		dev->iflink = -1;
-		dev_hold(dev);
-
+		/* Can't do dev_hold here in case
+		 *  register_netdev gets called first.
+		 */
+		atomic_set(&dev->refcnt,1);
 		/*
 		 * Allocate name. If the init() fails
 		 * the name will be reissued correctly.

             reply	other threads:[~2001-06-11 18:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-11 18:32 DJBARROW [this message]
2001-06-12  3:18 ` bug in /net/core/dev.c David S. Miller
  -- strict thread matches above, loose matches on Subject: below --
2001-06-12 14:17 DJBARROW
2001-06-12 14:57 ` David S. Miller
2001-06-12 15:34   ` Keith Owens
2001-06-12 15:46     ` David S. Miller
2001-06-12 16:11       ` Keith Owens
2001-06-12 16:43 DJBARROW
2001-06-12 16:51 ` David S. Miller
2001-06-12 17:02 ` Keith Owens
2001-06-12 17:05 Ulrich.Weigand
2001-06-12 17:20 ` Keith Owens
2001-06-12 18:38 DJBARROW
2001-06-12 18:44 ` David S. Miller
2001-06-13 10:03 DJBARROW
2001-06-13 10:18 ` David S. Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=C1256A68.0065E17F.00@d12mta09.de.ibm.com \
    --to=djbarrow@de.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.