lkml.org 
[lkml]   [2019]   [Aug]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] ocfs2: need to check return value from kobject_set_name()
Date
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
\
 
 \ /
  Last update: 2019-08-13 14:56    [W:0.021 / U:0.360 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site