]> git.baikalelectronics.ru Git - kernel.git/commit
Driver-core: Fix bogus 0 error return in device_add()
authorThomas Gleixner <tglx@linutronix.de>
Thu, 10 Dec 2009 19:32:49 +0000 (19:32 +0000)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 23 Dec 2009 19:23:44 +0000 (11:23 -0800)
commit3a2d2b5bd9a00a8577dde99a4f68ee3c8c26c034
treee4c1fc9b2771eb95b9206668b2f1f7798088e1ab
parentf6370c7668703d9fad17b8a4faf1f42cc8157e6b
Driver-core: Fix bogus 0 error return in device_add()

If device_add() is called with a device which does not have dev->p set
up, then device_private_init() is called. If that succeeds, then the
error variable is set to 0. Now if the dev_name(dev) check further
down fails, then device_add() correctly terminates, but returns 0.
That of course lets the driver progress. If later another driver uses
this half set up device as parent then device_add() of the child
device explodes and renders sysfs completely unusable.

Set the error to -EINVAL if dev_name() check fails.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: "Hans J. Koch" <hjk@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/core.c