Messages in this thread Patch in this message | ![/](/images/icornerl.gif) | | From | yu kuai <> | Subject | [PATCH] ocfs2: need to check return value from kobject_set_name() | Date | Tue, 13 Aug 2019 20:50:38 +0800 |
| |
Since kobject_set_name() might return an error, the return value need to be checked, otherwise there will be a warn:
mlog_sys_init kset_register kobject_add_internal if (!kobj->name || !kobj->name[0]) { WARN(...); return -EINVAL; }
Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: yu kuai <yukuai3@huawei.com> --- fs/ocfs2/cluster/masklog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index d331c23..4fcef46 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -178,7 +178,8 @@ int mlog_sys_init(struct kset *o2cb_kset) } mlog_attr_ptrs[i] = NULL; - kobject_set_name(&mlog_kset.kobj, "logmask"); + if (!kobject_set_name(&mlog_kset.kobj, "logmask")) + return -EINVAL; mlog_kset.kobj.kset = o2cb_kset; return kset_register(&mlog_kset); } -- 2.7.4
| ![\](/images/icornerr.gif) |