public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drivers: base: core: do not put noninitialized devices
@ 2010-11-19 18:41 Vasiliy Kulikov
  2010-11-19 19:02 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Vasiliy Kulikov @ 2010-11-19 18:41 UTC (permalink / raw)
  To: kernel-janitors; +Cc: Greg Kroah-Hartman, linux-kernel

If kobject_set_name_vargs() fails then put_device() frees
device with zero kobj->state_initialized.  This leads to WARN().
Divide device_register() call to device_initialize() call before
kobject_set_name_vargs() and device_add() call after it.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Compile tested only.

 drivers/base/core.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 46ff6c2..833ccf3 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1424,11 +1424,12 @@ struct device *device_create_vargs(struct class *class, struct device *parent,
 	dev->release = device_create_release;
 	dev_set_drvdata(dev, drvdata);
 
+	device_initialize(dev);
 	retval = kobject_set_name_vargs(&dev->kobj, fmt, args);
 	if (retval)
 		goto error;
 
-	retval = device_register(dev);
+	retval = device_add(dev);
 	if (retval)
 		goto error;
 
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-11-20  9:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-19 18:41 [PATCH] drivers: base: core: do not put noninitialized devices Vasiliy Kulikov
2010-11-19 19:02 ` Greg KH
2010-11-19 19:14   ` Vasiliy Kulikov
2010-11-19 19:17     ` Vasiliy Kulikov
2010-11-19 20:57     ` Greg KH
2010-11-20  9:00       ` Vasiliy Kulikov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox