提交 e6309e75 编写于 作者: T Thomas Gleixner 提交者: Greg Kroah-Hartman

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: NThomas Gleixner <tglx@linutronix.de>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: "Hans J. Koch" <hjk@linutronix.de>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 099c2f21
......@@ -909,8 +909,10 @@ int device_add(struct device *dev)
dev->init_name = NULL;
}
if (!dev_name(dev))
if (!dev_name(dev)) {
error = -EINVAL;
goto name_error;
}
pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册