diff options
author | Jan Kara <jack@suse.cz> | 2017-03-23 03:37:01 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-14 22:02:59 +0300 |
commit | dea1b68ece028bc6676fb620b55e28d4125b4b84 (patch) | |
tree | 2b3d104ee9bad0d218ecad55239dbccacca28a17 /lib/kobject.c | |
parent | 3e8701c52068b6f224f103ab28d9c827b4d1257d (diff) | |
download | linux-dea1b68ece028bc6676fb620b55e28d4125b4b84.tar.xz |
kobject: Export kobject_get_unless_zero()
commit c70c176ff8c3ff0ac6ef9a831cd591ea9a66bd1a upstream.
Make the function available for outside use and fortify it against NULL
kobject.
CC: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'lib/kobject.c')
-rw-r--r-- | lib/kobject.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/kobject.c b/lib/kobject.c index 35d490b02cdd..cebbe79d2c65 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -599,12 +599,15 @@ struct kobject *kobject_get(struct kobject *kobj) } EXPORT_SYMBOL(kobject_get); -static struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj) +struct kobject * __must_check kobject_get_unless_zero(struct kobject *kobj) { + if (!kobj) + return NULL; if (!kref_get_unless_zero(&kobj->kref)) kobj = NULL; return kobj; } +EXPORT_SYMBOL(kobject_get_unless_zero); /* * kobject_cleanup - free kobject resources. |