Re: bug in /net/core/dev.c

DJBARROW@de.ibm.com
Tue, 12 Jun 2001 16:17:48 +0200


--0__=FiHzD00gsc4wc7SCeTJXS18vd4RuIoG5jpxlwkSdIYn3T2EuunVOWB8J
Content-type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi Alan/Dave
Here is a better version of the patch I think it cuts about 15 lines out of
dev.c & I think logically it is more bulletproof than my previous attempt.

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

Hi Dave,

On 390 it is very easy to hotplug devices under VM.

We do it all the time using the channel device layer on s/390, so users
can reconfigure devices if they misconfigure them.

If it can be registered it should be able to be unregistered.

Cornelia Huck in our group in boeblingen noticed the bug too.

Please respond to "David S. Miller" <davem@redhat.com>

To: Denis Joseph Barrow/Germany/Contr/IBM@IBMDE
cc: linux-kernel@vger.kernel.org
Subject: Re: bug in /net/core/dev.c

DJBARROW@de.ibm.com writes:
> 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.

When will devices built statically into the kernel ever be
unregister'd?

Later,
David S. Miller
davem@redhat.com

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.

--0__=FiHzD00gsc4wc7SCeTJXS18vd4RuIoG5jpxlwkSdIYn3T2EuunVOWB8J
Content-type: application/octet-stream;
name="dev.c.2.4.5.v2.patch"
Content-Disposition: attachment; filename="dev.c.2.4.5.v2.patch"
Content-transfer-encoding: base64

LS0tIG5ldC9jb3JlL2Rldi5vbGQuYwlXZWQgTWF5IDMwIDE0OjI0OjQ3IDIwMDEKKysrIG5ldC9j
b3JlL2Rldi5jCVR1ZSBKdW4gMTIgMTU6Mzc6NTggMjAwMQp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UOwotCQkJ
fQotCQl9Ci0JCWRldi0+bmV4dCA9IE5VTEw7Ci0JCXdyaXRlX2xvY2tfYmgoJmRldl9iYXNlX2xv
Y2spOwotCQkqZHAgPSBkZXY7Ci0JCWRldl9ob2xkKGRldik7Ci0JCXdyaXRlX3VubG9ja19iaCgm
ZGV2X2Jhc2VfbG9jayk7Ci0KLQkJLyoKLQkJICoJRGVmYXVsdCBpbml0aWFsIHN0YXRlIGF0IHJl
Z2lzdHJ5IGlzIHRoYXQgdGhlCi0JCSAqCWRldmljZSBpcyBwcmVzZW50LgotCQkgKi8KLQotCQlz
ZXRfYml0KF9fTElOS19TVEFURV9QUkVTRU5ULCAmZGV2LT5zdGF0ZSk7Ci0KLQkJcmV0dXJuIDA7
Ci0JfQotCisJaWYgKGRldl9ib290X3BoYXNlKQorCQluZXRfZGV2X2luaXQoKTsKICNpZmRlZiBD
T05GSUdfTkVUX0RJVkVSVAogCXJldCA9IGFsbG9jX2RpdmVydF9ibGsoZGV2KTsKIAlpZiAocmV0
KQpAQCAtMjY3OSw3ICsyNjQ0LDkgQEAKIHsKIAlzdHJ1Y3QgbmV0X2RldmljZSAqZGV2LCAqKmRw
OwogCWludCBpOwotCisJCisJaWYoIWRldl9ib290X3BoYXNlKQorCQlyZXR1cm4gMDsKICNpZmRl
ZiBDT05GSUdfTkVUX1NDSEVECiAJcGt0c2NoZWRfaW5pdCgpOwogI2VuZGlmCg==

--0__=FiHzD00gsc4wc7SCeTJXS18vd4RuIoG5jpxlwkSdIYn3T2EuunVOWB8J--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/