Skip to contentSkip to conversation

kobject: Restore old behaviour of kobject_del(NULL)

PATCH In review Andy Shevchenko 3 participants 5 messages Aug 3, 2020 – Aug 25, 2020

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

PATCH v2 1/1 kobject: Restore old behaviour of kobject_del(NULL)

The commit 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()") inadvertently dropped a possibility to call kobject_del() with NULL pointer. Restore the old behaviour.

Fixes 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()")
Cc Heikki Krogerus <[email protected]>

---
v2: replaced ?: with plain conditional (Greg)

 lib/kobject.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/kobject.c +5 -1
index 3afb939f2a1c..9dce68c378e6 100644
@@ -637,8 +637,12 @@ static void __kobject_del(struct kobject *kobj)
  */
 void kobject_del(struct kobject *kobj)
 {
-	struct kobject *parent = kobj->parent;
+	struct kobject *parent;
+
+	if (!kobj)
+		return;
 
+	parent = kobj->parent;
 	__kobject_del(kobj);
 	kobject_put(parent);
 }
Signature · 1 line
2.27.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Andy Shevchenko

The commit 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()") inadvertently dropped a possibility to call kobject_del() with NULL pointer. Restore the old behaviour.

Fixes 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()")

Sorry, I should use my suse mailbox for that.

Quoted 2 lines

Thanks,
Qu

Quoted 24 lines

---
v2: replaced ?: with plain conditional (Greg)

 lib/kobject.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
lib/kobject.c +5 -1
index 3afb939f2a1c..9dce68c378e6 100644
@@ -637,8 +637,12 @@ static void __kobject_del(struct kobject *kobj)
  */
 void kobject_del(struct kobject *kobj)
 {
-	struct kobject *parent = kobj->parent;
+	struct kobject *parent;
+
+	if (!kobj)
+		return;
 
+	parent = kobj->parent;
 	__kobject_del(kobj);
 	kobject_put(parent);
 }
#2 lore raw
In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko

The commit 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()") inadvertently dropped a possibility to call kobject_del() with NULL pointer. Restore the old behaviour.

Quoted 8 lines
Fixes 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()")
Cc Heikki Krogerus <[email protected]>

---
v2: replaced ?: with plain conditional (Greg)

 lib/kobject.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Thanks, much better, will queue up after -rc1 is out.

greg k-h

#3 lore raw
Quoted 14 lines · Greg Kroah-Hartman
Quoted 4 lines · Andy Shevchenko

The commit 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()") inadvertently dropped a possibility to call kobject_del() with NULL pointer. Restore the old behaviour.

Quoted 8 lines
Fixes 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()")
Cc Heikki Krogerus <[email protected]>

---
v2: replaced ?: with plain conditional (Greg)

 lib/kobject.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 1 line

Thanks, much better, will queue up after -rc1 is out.

Shouldn't be this taken care of?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 15 lines · Andy Shevchenko
Quoted 14 lines · Greg Kroah-Hartman
Quoted 12 lines · Andy Shevchenko

The commit 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()") inadvertently dropped a possibility to call kobject_del() with NULL pointer. Restore the old behaviour.

Fixes 079ad2fb4bf9 ("kobject: Avoid premature parent object freeing in kobject_cleanup()")
Cc Heikki Krogerus <[email protected]>

---
v2: replaced ?: with plain conditional (Greg)

 lib/kobject.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
Quoted 3 lines
Quoted 1 line

Thanks, much better, will queue up after -rc1 is out.

Shouldn't be this taken care of?

Yes, will get to it soon, after -rc1 is tough, combined with Plumbers...

greg k-h