Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+73 -38
-1
fs/orangefs/file.c
··· 273 273 gossip_debug(GOSSIP_FILE_DEBUG, 274 274 "%s(%pU): PUT buffer_index %d\n", 275 275 __func__, handle, buffer_index); 276 - buffer_index = -1; 277 276 } 278 277 op_release(new_op); 279 278 return ret;
-2
fs/orangefs/inode.c
··· 530 530 size_t count = iov_iter_count(iter); 531 531 ssize_t total_count = 0; 532 532 ssize_t ret = -EINVAL; 533 - int i = 0; 534 533 535 534 gossip_debug(GOSSIP_FILE_DEBUG, 536 535 "%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n", ··· 555 556 while (iov_iter_count(iter)) { 556 557 size_t each_count = iov_iter_count(iter); 557 558 size_t amt_complete; 558 - i++; 559 559 560 560 /* how much to transfer in this loop iteration */ 561 561 if (each_count > orangefs_bufmap_size_query())
+6 -23
fs/orangefs/orangefs-debugfs.c
··· 194 194 */ 195 195 static void orangefs_kernel_debug_init(void) 196 196 { 197 - int rc = -ENOMEM; 198 - char *k_buffer = NULL; 197 + static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; 199 198 200 199 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); 201 - 202 - k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); 203 - if (!k_buffer) 204 - goto out; 205 200 206 201 if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 207 202 strcpy(k_buffer, kernel_debug_string); ··· 208 213 209 214 debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer, 210 215 &kernel_debug_fops); 211 - 212 - out: 213 - gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); 214 216 } 215 217 216 218 217 219 void orangefs_debugfs_cleanup(void) 218 220 { 219 221 debugfs_remove_recursive(debug_dir); 222 + kfree(debug_help_string); 223 + debug_help_string = NULL; 220 224 } 221 225 222 226 /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */ ··· 291 297 /* 292 298 * initialize the client-debug file. 293 299 */ 294 - static int orangefs_client_debug_init(void) 300 + static void orangefs_client_debug_init(void) 295 301 { 296 302 297 - int rc = -ENOMEM; 298 - char *c_buffer = NULL; 303 + static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; 299 304 300 305 gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); 301 - 302 - c_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); 303 - if (!c_buffer) 304 - goto out; 305 306 306 307 if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { 307 308 strcpy(c_buffer, client_debug_string); ··· 311 322 debug_dir, 312 323 c_buffer, 313 324 &kernel_debug_fops); 314 - 315 - rc = 0; 316 - 317 - out: 318 - 319 - gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); 320 - return rc; 321 325 } 322 326 323 327 /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/ ··· 653 671 memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE); 654 672 strlcat(debug_help_string, new, string_size); 655 673 mutex_unlock(&orangefs_help_file_lock); 674 + kfree(new); 656 675 } 657 676 658 677 rc = 0;
+4 -4
fs/orangefs/orangefs-mod.c
··· 141 141 gossip_err("%s: could not initialize device subsystem %d!\n", 142 142 __func__, 143 143 ret); 144 - goto cleanup_device; 144 + goto cleanup_sysfs; 145 145 } 146 146 147 147 ret = register_filesystem(&orangefs_fs_type); ··· 152 152 goto out; 153 153 } 154 154 155 - orangefs_sysfs_exit(); 156 - 157 - cleanup_device: 158 155 orangefs_dev_cleanup(); 156 + 157 + cleanup_sysfs: 158 + orangefs_sysfs_exit(); 159 159 160 160 sysfs_init_failed: 161 161 orangefs_debugfs_cleanup();
+63 -8
fs/orangefs/orangefs-sysfs.c
··· 896 896 }; 897 897 ATTRIBUTE_GROUPS(orangefs_default); 898 898 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 + 899 907 static struct kobj_type orangefs_ktype = { 900 908 .sysfs_ops = &orangefs_sysfs_ops, 901 909 .default_groups = orangefs_default_groups, 910 + .release = orangefs_obj_release, 902 911 }; 903 912 904 913 static struct orangefs_attribute acache_hard_limit_attribute = ··· 943 934 }; 944 935 ATTRIBUTE_GROUPS(acache_orangefs_default); 945 936 937 + static struct kobject *acache_orangefs_obj; 938 + 939 + static void acache_orangefs_obj_release(struct kobject *kobj) 940 + { 941 + kfree(acache_orangefs_obj); 942 + acache_orangefs_obj = NULL; 943 + } 944 + 946 945 static struct kobj_type acache_orangefs_ktype = { 947 946 .sysfs_ops = &orangefs_sysfs_ops, 948 947 .default_groups = acache_orangefs_default_groups, 948 + .release = acache_orangefs_obj_release, 949 949 }; 950 950 951 951 static struct orangefs_attribute capcache_hard_limit_attribute = ··· 990 972 }; 991 973 ATTRIBUTE_GROUPS(capcache_orangefs_default); 992 974 975 + static struct kobject *capcache_orangefs_obj; 976 + 977 + static void capcache_orangefs_obj_release(struct kobject *kobj) 978 + { 979 + kfree(capcache_orangefs_obj); 980 + capcache_orangefs_obj = NULL; 981 + } 982 + 993 983 static struct kobj_type capcache_orangefs_ktype = { 994 984 .sysfs_ops = &orangefs_sysfs_ops, 995 985 .default_groups = capcache_orangefs_default_groups, 986 + .release = capcache_orangefs_obj_release, 996 987 }; 997 988 998 989 static struct orangefs_attribute ccache_hard_limit_attribute = ··· 1037 1010 }; 1038 1011 ATTRIBUTE_GROUPS(ccache_orangefs_default); 1039 1012 1013 + static struct kobject *ccache_orangefs_obj; 1014 + 1015 + static void ccache_orangefs_obj_release(struct kobject *kobj) 1016 + { 1017 + kfree(ccache_orangefs_obj); 1018 + ccache_orangefs_obj = NULL; 1019 + } 1020 + 1040 1021 static struct kobj_type ccache_orangefs_ktype = { 1041 1022 .sysfs_ops = &orangefs_sysfs_ops, 1042 1023 .default_groups = ccache_orangefs_default_groups, 1024 + .release = ccache_orangefs_obj_release, 1043 1025 }; 1044 1026 1045 1027 static struct orangefs_attribute ncache_hard_limit_attribute = ··· 1084 1048 }; 1085 1049 ATTRIBUTE_GROUPS(ncache_orangefs_default); 1086 1050 1051 + static struct kobject *ncache_orangefs_obj; 1052 + 1053 + static void ncache_orangefs_obj_release(struct kobject *kobj) 1054 + { 1055 + kfree(ncache_orangefs_obj); 1056 + ncache_orangefs_obj = NULL; 1057 + } 1058 + 1087 1059 static struct kobj_type ncache_orangefs_ktype = { 1088 1060 .sysfs_ops = &orangefs_sysfs_ops, 1089 1061 .default_groups = ncache_orangefs_default_groups, 1062 + .release = ncache_orangefs_obj_release, 1090 1063 }; 1091 1064 1092 1065 static struct orangefs_attribute pc_acache_attribute = ··· 1124 1079 }; 1125 1080 ATTRIBUTE_GROUPS(pc_orangefs_default); 1126 1081 1082 + static struct kobject *pc_orangefs_obj; 1083 + 1084 + static void pc_orangefs_obj_release(struct kobject *kobj) 1085 + { 1086 + kfree(pc_orangefs_obj); 1087 + pc_orangefs_obj = NULL; 1088 + } 1089 + 1127 1090 static struct kobj_type pc_orangefs_ktype = { 1128 1091 .sysfs_ops = &orangefs_sysfs_ops, 1129 1092 .default_groups = pc_orangefs_default_groups, 1093 + .release = pc_orangefs_obj_release, 1130 1094 }; 1131 1095 1132 1096 static struct orangefs_attribute stats_reads_attribute = ··· 1157 1103 }; 1158 1104 ATTRIBUTE_GROUPS(stats_orangefs_default); 1159 1105 1106 + static struct kobject *stats_orangefs_obj; 1107 + 1108 + static void stats_orangefs_obj_release(struct kobject *kobj) 1109 + { 1110 + kfree(stats_orangefs_obj); 1111 + stats_orangefs_obj = NULL; 1112 + } 1113 + 1160 1114 static struct kobj_type stats_orangefs_ktype = { 1161 1115 .sysfs_ops = &orangefs_sysfs_ops, 1162 1116 .default_groups = stats_orangefs_default_groups, 1117 + .release = stats_orangefs_obj_release, 1163 1118 }; 1164 - 1165 - static struct kobject *orangefs_obj; 1166 - static struct kobject *acache_orangefs_obj; 1167 - static struct kobject *capcache_orangefs_obj; 1168 - static struct kobject *ccache_orangefs_obj; 1169 - static struct kobject *ncache_orangefs_obj; 1170 - static struct kobject *pc_orangefs_obj; 1171 - static struct kobject *stats_orangefs_obj; 1172 1119 1173 1120 int orangefs_sysfs_init(void) 1174 1121 {