Skip to content

Commit 40b8b82

Browse files
andy-shevgregkh
authored andcommitted
kobject: Restore old behaviour of kobject_del(NULL)
The commit 079ad2f ("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: 079ad2f ("kobject: Avoid premature parent object freeing in kobject_cleanup()") Cc: stable <stable@vger.kernel.org> Reported-by: Qu Wenruo <quwenruo.btrfs@gmx.com> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Link: https://lore.kernel.org/r/20200803082706.65347-1-andriy.shevchenko@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4965b8c commit 40b8b82

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/kobject.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,12 @@ static void __kobject_del(struct kobject *kobj)
637637
*/
638638
void kobject_del(struct kobject *kobj)
639639
{
640-
struct kobject *parent = kobj->parent;
640+
struct kobject *parent;
641+
642+
if (!kobj)
643+
return;
641644

645+
parent = kobj->parent;
642646
__kobject_del(kobj);
643647
kobject_put(parent);
644648
}

0 commit comments

Comments
 (0)