Skip to contentSkip to conversation

Fixup initialisation oops for anonymous transport classes

PATCH In review Hannes Reinecke 2 participants 2 messages Mar 18, 2008 – Mar 20, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/8 Fixup initialisation oops for anonymous transport classes

Anonymous transport classes might call transport_add_class_devices with NULL classdev.

---
 drivers/base/transport_class.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/base/transport_class.c +7 -1
index 72cf462..61a611c 100644
@@ -150,10 +150,16 @@ static int transport_add_class_device(struct attribute_container *cont,
 				      struct device *dev,
 				      struct device *classdev)
 {
-	int error = attribute_container_add_class_device(classdev);
+	int error;
 	struct transport_container *tcont = 
 		attribute_container_to_transport_container(cont);
 
+	/* NULL if called from anonymous transport classes */
+	if (!classdev)
+		return 0;
+
+	error = attribute_container_add_class_device(classdev);
+
 	if (!error && tcont->statistics)
 		error = sysfs_create_group(&classdev->kobj, tcont->statistics);
 
Signature · 1 line
1.5.2.4
maintainer
#1 lore raw
Quoted 2 lines · Hannes Reinecke

Anonymous transport classes might call transport_add_class_devices with NULL classdev.

They do ... but it doesn't cause an oops. class_device_add first calls class_device_get() which returns -EINVAL for a NULL classdev. It looks like device_add() does exactly the same thing in the new scheme, so what oops were you seeing?

James