mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2024-12-29 17:22:07 +00:00
kobject: fix dereference before null check on kobj
The kobj pointer is being null-checked so potentially it could be null,
however, the ktype declaration before the null check is dereferencing kobj
hence we have a potential null pointer deference. Fix this by moving the
assignment of ktype after kobj has been null checked.
Addresses-Coverity: ("Dereference before null check")
Fixes: aa30f47cf6
("kobject: Add support for default attribute groups to kobj_type")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
391c0325cc
commit
3d378dc713
@ -603,12 +603,13 @@ EXPORT_SYMBOL_GPL(kobject_move);
|
||||
void kobject_del(struct kobject *kobj)
|
||||
{
|
||||
struct kernfs_node *sd;
|
||||
const struct kobj_type *ktype = get_ktype(kobj);
|
||||
const struct kobj_type *ktype;
|
||||
|
||||
if (!kobj)
|
||||
return;
|
||||
|
||||
sd = kobj->sd;
|
||||
ktype = get_ktype(kobj);
|
||||
|
||||
if (ktype)
|
||||
sysfs_remove_groups(kobj, ktype->default_groups);
|
||||
|
Loading…
Reference in New Issue
Block a user