History

Merge tag 'for-linus-6.2-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux

Pull orangefs updates from Mike Marshall: - fix problems with memory leaks on exit in sysfs and debufs (Zhang) - remove an unused variable and an unneeded assignment (Colin) * tag 'for-linus-6.2-ofs1' of git://git.kernel.org/pub/scm/linux/kernel/git/hubcap/linux: orangefs: Fix kmemleak in orangefs_{kernel,client}_debug_init() orangefs: Fix kmemleak in orangefs_sysfs_init() orangefs: Fix kmemleak in orangefs_prepare_debugfs_help_string() orangefs: Fix sysfs not cleanup when dev init failed orangefs: remove redundant assignment to variable buffer_index orangefs: remove variable i

Linus Torvalds committed 3 years ago

Commit 6f1f5ca2 parents cfb3162 31720a25 files · +73 −38Browse files

Unified · Split

5 files
  1. fs/orangefs/file.c +0 −1
  2. fs/orangefs/inode.c +0 −2
  3. fs/orangefs/orangefs-debugfs.c +6 −23
  4. fs/orangefs/orangefs-mod.c +4 −4
  5. fs/orangefs/orangefs-sysfs.c +63 −8
fs/orangefs/file.c+0−1
@@ -273,7 +273,6 @@ out: · 272 unmodified lines
273273 gossip_debug(GOSSIP_FILE_DEBUG,
274274 "%s(%pU): PUT buffer_index %d\n",
275275 __func__, handle, buffer_index);
276− buffer_index = -1;
277276 }
278277 op_release(new_op);
279278 return ret;
fs/orangefs/inode.c+0−2
@@ -530,7 +530,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, · 529 unmodified lines
530530 size_t count = iov_iter_count(iter);
531531 ssize_t total_count = 0;
532532 ssize_t ret = -EINVAL;
533− int i = 0;
534533
535534 gossip_debug(GOSSIP_FILE_DEBUG,
536535 "%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n",
@@ -556,7 +555,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, · 19 unmodified lines
556555 while (iov_iter_count(iter)) {
557556 size_t each_count = iov_iter_count(iter);
558557 size_t amt_complete;
559− i++;
560558
561559 /* how much to transfer in this loop iteration */
562560 if (each_count > orangefs_bufmap_size_query())
fs/orangefs/orangefs-debugfs.c+6−23
@@ -194,15 +194,10 @@ void orangefs_debugfs_init(int debug_mask) · 193 unmodified lines
194194 */
195195 static void orangefs_kernel_debug_init(void)
196196 {
197− int rc = -ENOMEM;
198− char *k_buffer = NULL;
197+ static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
199198
200199 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
201200
202− k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
203− if (!k_buffer)
204− goto out;
205−
206201 if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
207202 strcpy(k_buffer, kernel_debug_string);
208203 strcat(k_buffer, "\n");
@@ -213,15 +208,14 @@ static void orangefs_kernel_debug_init(void) · 4 unmodified lines
213208
214209 debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer,
215210 &kernel_debug_fops);
216−
217−out:
218− gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
219211 }
220212
221213
222214 void orangefs_debugfs_cleanup(void)
223215 {
224216 debugfs_remove_recursive(debug_dir);
217+ kfree(debug_help_string);
218+ debug_help_string = NULL;
225219 }
226220
227221 /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */
@@ -297,18 +291,13 @@ static int help_show(struct seq_file *m, void *v) · 69 unmodified lines
297291 /*
298292 * initialize the client-debug file.
299293 */
300−static int orangefs_client_debug_init(void)
294+static void orangefs_client_debug_init(void)
301295 {
302296
303− int rc = -ENOMEM;
304− char *c_buffer = NULL;
297+ static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { };
305298
306299 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__);
307300
308− c_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL);
309− if (!c_buffer)
310− goto out;
311−
312301 if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) {
313302 strcpy(c_buffer, client_debug_string);
314303 strcat(c_buffer, "\n");
@@ -322,13 +311,6 @@ static int orangefs_client_debug_init(void) · 7 unmodified lines
322311 debug_dir,
323312 c_buffer,
324313 &kernel_debug_fops);
325−
326− rc = 0;
327−
328−out:
329−
330− gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc);
331− return rc;
332314 }
333315
334316 /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/
@@ -671,6 +653,7 @@ int orangefs_prepare_debugfs_help_string(int at_boot) · 336 unmodified lines
671653 memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE);
672654 strlcat(debug_help_string, new, string_size);
673655 mutex_unlock(&orangefs_help_file_lock);
656+ kfree(new);
674657 }
675658
676659 rc = 0;
fs/orangefs/orangefs-mod.c+4−4
@@ -141,7 +141,7 @@ static int __init orangefs_init(void) · 140 unmodified lines
141141 gossip_err("%s: could not initialize device subsystem %d!\n",
142142 __func__,
143143 ret);
144− goto cleanup_device;
144+ goto cleanup_sysfs;
145145 }
146146
147147 ret = register_filesystem(&orangefs_fs_type);
@@ -152,11 +152,11 @@ static int __init orangefs_init(void) · 4 unmodified lines
152152 goto out;
153153 }
154154
155− orangefs_sysfs_exit();
156−
157−cleanup_device:
158155 orangefs_dev_cleanup();
159156
157+cleanup_sysfs:
158+ orangefs_sysfs_exit();
159+
160160 sysfs_init_failed:
161161 orangefs_debugfs_cleanup();
162162
fs/orangefs/orangefs-sysfs.c+63−8
@@ -896,9 +896,18 @@ static struct attribute *orangefs_default_attrs[] = { · 895 unmodified lines
896896 };
897897 ATTRIBUTE_GROUPS(orangefs_default);
898898
899+static struct kobject *orangefs_obj;
900+
901+static void orangefs_obj_release(struct kobject *kobj)
902+{
903+ kfree(orangefs_obj);
904+ orangefs_obj = NULL;
905+}
906+
899907 static struct kobj_type orangefs_ktype = {
900908 .sysfs_ops = &orangefs_sysfs_ops,
901909 .default_groups = orangefs_default_groups,
910+ .release = orangefs_obj_release,
902911 };
903912
904913 static struct orangefs_attribute acache_hard_limit_attribute =
@@ -934,9 +943,18 @@ static struct attribute *acache_orangefs_default_attrs[] = { · 29 unmodified lines
934943 };
935944 ATTRIBUTE_GROUPS(acache_orangefs_default);
936945
946+static struct kobject *acache_orangefs_obj;
947+
948+static void acache_orangefs_obj_release(struct kobject *kobj)
949+{
950+ kfree(acache_orangefs_obj);
951+ acache_orangefs_obj = NULL;
952+}
953+
937954 static struct kobj_type acache_orangefs_ktype = {
938955 .sysfs_ops = &orangefs_sysfs_ops,
939956 .default_groups = acache_orangefs_default_groups,
957+ .release = acache_orangefs_obj_release,
940958 };
941959
942960 static struct orangefs_attribute capcache_hard_limit_attribute =
@@ -972,9 +990,18 @@ static struct attribute *capcache_orangefs_default_attrs[] = { · 29 unmodified lines
972990 };
973991 ATTRIBUTE_GROUPS(capcache_orangefs_default);
974992
993+static struct kobject *capcache_orangefs_obj;
994+
995+static void capcache_orangefs_obj_release(struct kobject *kobj)
996+{
997+ kfree(capcache_orangefs_obj);
998+ capcache_orangefs_obj = NULL;
999+}
1000+
9751001 static struct kobj_type capcache_orangefs_ktype = {
9761002 .sysfs_ops = &orangefs_sysfs_ops,
9771003 .default_groups = capcache_orangefs_default_groups,
1004+ .release = capcache_orangefs_obj_release,
9781005 };
9791006
9801007 static struct orangefs_attribute ccache_hard_limit_attribute =
@@ -1010,9 +1037,18 @@ static struct attribute *ccache_orangefs_default_attrs[] = { · 29 unmodified lines
10101037 };
10111038 ATTRIBUTE_GROUPS(ccache_orangefs_default);
10121039
1040+static struct kobject *ccache_orangefs_obj;
1041+
1042+static void ccache_orangefs_obj_release(struct kobject *kobj)
1043+{
1044+ kfree(ccache_orangefs_obj);
1045+ ccache_orangefs_obj = NULL;
1046+}
1047+
10131048 static struct kobj_type ccache_orangefs_ktype = {
10141049 .sysfs_ops = &orangefs_sysfs_ops,
10151050 .default_groups = ccache_orangefs_default_groups,
1051+ .release = ccache_orangefs_obj_release,
10161052 };
10171053
10181054 static struct orangefs_attribute ncache_hard_limit_attribute =
@@ -1048,9 +1084,18 @@ static struct attribute *ncache_orangefs_default_attrs[] = { · 29 unmodified lines
10481084 };
10491085 ATTRIBUTE_GROUPS(ncache_orangefs_default);
10501086
1087+static struct kobject *ncache_orangefs_obj;
1088+
1089+static void ncache_orangefs_obj_release(struct kobject *kobj)
1090+{
1091+ kfree(ncache_orangefs_obj);
1092+ ncache_orangefs_obj = NULL;
1093+}
1094+
10511095 static struct kobj_type ncache_orangefs_ktype = {
10521096 .sysfs_ops = &orangefs_sysfs_ops,
10531097 .default_groups = ncache_orangefs_default_groups,
1098+ .release = ncache_orangefs_obj_release,
10541099 };
10551100
10561101 static struct orangefs_attribute pc_acache_attribute =
@@ -1079,9 +1124,18 @@ static struct attribute *pc_orangefs_default_attrs[] = { · 22 unmodified lines
10791124 };
10801125 ATTRIBUTE_GROUPS(pc_orangefs_default);
10811126
1127+static struct kobject *pc_orangefs_obj;
1128+
1129+static void pc_orangefs_obj_release(struct kobject *kobj)
1130+{
1131+ kfree(pc_orangefs_obj);
1132+ pc_orangefs_obj = NULL;
1133+}
1134+
10821135 static struct kobj_type pc_orangefs_ktype = {
10831136 .sysfs_ops = &orangefs_sysfs_ops,
10841137 .default_groups = pc_orangefs_default_groups,
1138+ .release = pc_orangefs_obj_release,
10851139 };
10861140
10871141 static struct orangefs_attribute stats_reads_attribute =
@@ -1103,19 +1157,20 @@ static struct attribute *stats_orangefs_default_attrs[] = { · 15 unmodified lines
11031157 };
11041158 ATTRIBUTE_GROUPS(stats_orangefs_default);
11051159
1160+static struct kobject *stats_orangefs_obj;
1161+
1162+static void stats_orangefs_obj_release(struct kobject *kobj)
1163+{
1164+ kfree(stats_orangefs_obj);
1165+ stats_orangefs_obj = NULL;
1166+}
1167+
11061168 static struct kobj_type stats_orangefs_ktype = {
11071169 .sysfs_ops = &orangefs_sysfs_ops,
11081170 .default_groups = stats_orangefs_default_groups,
1171+ .release = stats_orangefs_obj_release,
11091172 };
11101173
1111−static struct kobject *orangefs_obj;
1112−static struct kobject *acache_orangefs_obj;
1113−static struct kobject *capcache_orangefs_obj;
1114−static struct kobject *ccache_orangefs_obj;
1115−static struct kobject *ncache_orangefs_obj;
1116−static struct kobject *pc_orangefs_obj;
1117−static struct kobject *stats_orangefs_obj;
1118−
11191174 int orangefs_sysfs_init(void)
11201175 {
11211176 int rc = -EINVAL;