summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2019-05-01 13:43:17 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-05-01 15:08:38 +0200
commit3d378dc713f3ff4951d9a50c6a815f011e59da10 (patch)
tree3331ef1d2ee94ef2b273ab1ec058e63641250483 /lib
parent391c0325cc5f9e2daf9117825714d777b3595a42 (diff)
downloadlinux-3d378dc713f3ff4951d9a50c6a815f011e59da10.tar.bz2
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: aa30f47cf666 ("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>
Diffstat (limited to 'lib')
-rw-r--r--lib/kobject.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/kobject.c b/lib/kobject.c
index a30ee0467942..095bcb55c2ba 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -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);