Skip to content

Commit

Permalink
kobject: Restore old behaviour of kobject_del(NULL)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reported-by: Qu Wenruo <[email protected]>
Cc: Heikki Krogerus <[email protected]>
Signed-off-by: Andy Shevchenko <[email protected]>
Reviewed-by: Qu Wenruo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
andy-shev authored and gregkh committed Aug 28, 2020
1 parent 4965b8c commit 40b8b82
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/kobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 40b8b82

Please sign in to comment.