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
Unified · Split
| @@ -273,7 +273,6 @@ out: · 272 unmodified lines | |||
| 273 | gossip_debug(GOSSIP_FILE_DEBUG, | 273 | gossip_debug(GOSSIP_FILE_DEBUG, |
| 274 | "%s(%pU): PUT buffer_index %d\n", | 274 | "%s(%pU): PUT buffer_index %d\n", |
| 275 | __func__, handle, buffer_index); | 275 | __func__, handle, buffer_index); |
| 276 | buffer_index = -1; | ||
| 277 | } | 276 | } |
| 278 | op_release(new_op); | 277 | op_release(new_op); |
| 279 | return ret; | 278 | return ret; |
| @@ -530,7 +530,6 @@ static ssize_t orangefs_direct_IO(struct kiocb *iocb, · 529 unmodified lines | |||
| 530 | size_t count = iov_iter_count(iter); | 530 | size_t count = iov_iter_count(iter); |
| 531 | ssize_t total_count = 0; | 531 | ssize_t total_count = 0; |
| 532 | ssize_t ret = -EINVAL; | 532 | ssize_t ret = -EINVAL; |
| 533 | int i = 0; | ||
| 534 | 533 | ||
| 535 | gossip_debug(GOSSIP_FILE_DEBUG, | 534 | gossip_debug(GOSSIP_FILE_DEBUG, |
| 536 | "%s-BEGIN(%pU): count(%d) after estimate_max_iovecs.\n", | 535 | "%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 | |||
| 556 | while (iov_iter_count(iter)) { | 555 | while (iov_iter_count(iter)) { |
| 557 | size_t each_count = iov_iter_count(iter); | 556 | size_t each_count = iov_iter_count(iter); |
| 558 | size_t amt_complete; | 557 | size_t amt_complete; |
| 559 | i++; | ||
| 560 | 558 | ||
| 561 | /* how much to transfer in this loop iteration */ | 559 | /* how much to transfer in this loop iteration */ |
| 562 | if (each_count > orangefs_bufmap_size_query()) | 560 | if (each_count > orangefs_bufmap_size_query()) |
| @@ -194,15 +194,10 @@ void orangefs_debugfs_init(int debug_mask) · 193 unmodified lines | |||
| 194 | */ | 194 | */ |
| 195 | static void orangefs_kernel_debug_init(void) | 195 | static void orangefs_kernel_debug_init(void) |
| 196 | { | 196 | { |
| 197 | int rc = -ENOMEM; | 197 | static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; |
| 198 | char *k_buffer = NULL; | ||
| 199 | 198 | ||
| 200 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); | 199 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); |
| 201 | 200 | ||
| 202 | k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); | ||
| 203 | if (!k_buffer) | ||
| 204 | goto out; | ||
| 205 | |||
| 206 | if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { | 201 | if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { |
| 207 | strcpy(k_buffer, kernel_debug_string); | 202 | strcpy(k_buffer, kernel_debug_string); |
| 208 | strcat(k_buffer, "\n"); | 203 | strcat(k_buffer, "\n"); |
| @@ -213,15 +208,14 @@ static void orangefs_kernel_debug_init(void) · 4 unmodified lines | |||
| 213 | 208 | ||
| 214 | debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer, | 209 | debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer, |
| 215 | &kernel_debug_fops); | 210 | &kernel_debug_fops); |
| 216 | |||
| 217 | out: | ||
| 218 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); | ||
| 219 | } | 211 | } |
| 220 | 212 | ||
| 221 | 213 | ||
| 222 | void orangefs_debugfs_cleanup(void) | 214 | void orangefs_debugfs_cleanup(void) |
| 223 | { | 215 | { |
| 224 | debugfs_remove_recursive(debug_dir); | 216 | debugfs_remove_recursive(debug_dir); |
| 217 | kfree(debug_help_string); | ||
| 218 | debug_help_string = NULL; | ||
| 225 | } | 219 | } |
| 226 | 220 | ||
| 227 | /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */ | 221 | /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */ |
| @@ -297,18 +291,13 @@ static int help_show(struct seq_file *m, void *v) · 69 unmodified lines | |||
| 297 | /* | 291 | /* |
| 298 | * initialize the client-debug file. | 292 | * initialize the client-debug file. |
| 299 | */ | 293 | */ |
| 300 | static int orangefs_client_debug_init(void) | 294 | static void orangefs_client_debug_init(void) |
| 301 | { | 295 | { |
| 302 | 296 | ||
| 303 | int rc = -ENOMEM; | 297 | static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; |
| 304 | char *c_buffer = NULL; | ||
| 305 | 298 | ||
| 306 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); | 299 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); |
| 307 | 300 | ||
| 308 | c_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); | ||
| 309 | if (!c_buffer) | ||
| 310 | goto out; | ||
| 311 | |||
| 312 | if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { | 301 | if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { |
| 313 | strcpy(c_buffer, client_debug_string); | 302 | strcpy(c_buffer, client_debug_string); |
| 314 | strcat(c_buffer, "\n"); | 303 | strcat(c_buffer, "\n"); |
| @@ -322,13 +311,6 @@ static int orangefs_client_debug_init(void) · 7 unmodified lines | |||
| 322 | debug_dir, | 311 | debug_dir, |
| 323 | c_buffer, | 312 | c_buffer, |
| 324 | &kernel_debug_fops); | 313 | &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; | ||
| 332 | } | 314 | } |
| 333 | 315 | ||
| 334 | /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/ | 316 | /* 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 | |||
| 671 | memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE); | 653 | memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE); |
| 672 | strlcat(debug_help_string, new, string_size); | 654 | strlcat(debug_help_string, new, string_size); |
| 673 | mutex_unlock(&orangefs_help_file_lock); | 655 | mutex_unlock(&orangefs_help_file_lock); |
| 656 | kfree(new); | ||
| 674 | } | 657 | } |
| 675 | 658 | ||
| 676 | rc = 0; | 659 | rc = 0; |
| @@ -141,7 +141,7 @@ static int __init orangefs_init(void) · 140 unmodified lines | |||
| 141 | gossip_err("%s: could not initialize device subsystem %d!\n", | 141 | gossip_err("%s: could not initialize device subsystem %d!\n", |
| 142 | __func__, | 142 | __func__, |
| 143 | ret); | 143 | ret); |
| 144 | goto cleanup_device; | 144 | goto cleanup_sysfs; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | ret = register_filesystem(&orangefs_fs_type); | 147 | ret = register_filesystem(&orangefs_fs_type); |
| @@ -152,11 +152,11 @@ static int __init orangefs_init(void) · 4 unmodified lines | |||
| 152 | goto out; | 152 | goto out; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | orangefs_sysfs_exit(); | ||
| 156 | |||
| 157 | cleanup_device: | ||
| 158 | orangefs_dev_cleanup(); | 155 | orangefs_dev_cleanup(); |
| 159 | 156 | ||
| 157 | cleanup_sysfs: | ||
| 158 | orangefs_sysfs_exit(); | ||
| 159 | |||
| 160 | sysfs_init_failed: | 160 | sysfs_init_failed: |
| 161 | orangefs_debugfs_cleanup(); | 161 | orangefs_debugfs_cleanup(); |
| 162 | 162 | ||
| @@ -896,9 +896,18 @@ static struct attribute *orangefs_default_attrs[] = { · 895 unmodified lines | |||
| 896 | }; | 896 | }; |
| 897 | ATTRIBUTE_GROUPS(orangefs_default); | 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 | static struct kobj_type orangefs_ktype = { | 907 | static struct kobj_type orangefs_ktype = { |
| 900 | .sysfs_ops = &orangefs_sysfs_ops, | 908 | .sysfs_ops = &orangefs_sysfs_ops, |
| 901 | .default_groups = orangefs_default_groups, | 909 | .default_groups = orangefs_default_groups, |
| 910 | .release = orangefs_obj_release, | ||
| 902 | }; | 911 | }; |
| 903 | 912 | ||
| 904 | static struct orangefs_attribute acache_hard_limit_attribute = | 913 | static struct orangefs_attribute acache_hard_limit_attribute = |
| @@ -934,9 +943,18 @@ static struct attribute *acache_orangefs_default_attrs[] = { · 29 unmodified lines | |||
| 934 | }; | 943 | }; |
| 935 | ATTRIBUTE_GROUPS(acache_orangefs_default); | 944 | ATTRIBUTE_GROUPS(acache_orangefs_default); |
| 936 | 945 | ||
| 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 | |||
| 937 | static struct kobj_type acache_orangefs_ktype = { | 954 | static struct kobj_type acache_orangefs_ktype = { |
| 938 | .sysfs_ops = &orangefs_sysfs_ops, | 955 | .sysfs_ops = &orangefs_sysfs_ops, |
| 939 | .default_groups = acache_orangefs_default_groups, | 956 | .default_groups = acache_orangefs_default_groups, |
| 957 | .release = acache_orangefs_obj_release, | ||
| 940 | }; | 958 | }; |
| 941 | 959 | ||
| 942 | static struct orangefs_attribute capcache_hard_limit_attribute = | 960 | static struct orangefs_attribute capcache_hard_limit_attribute = |
| @@ -972,9 +990,18 @@ static struct attribute *capcache_orangefs_default_attrs[] = { · 29 unmodified lines | |||
| 972 | }; | 990 | }; |
| 973 | ATTRIBUTE_GROUPS(capcache_orangefs_default); | 991 | ATTRIBUTE_GROUPS(capcache_orangefs_default); |
| 974 | 992 | ||
| 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 | |||
| 975 | static struct kobj_type capcache_orangefs_ktype = { | 1001 | static struct kobj_type capcache_orangefs_ktype = { |
| 976 | .sysfs_ops = &orangefs_sysfs_ops, | 1002 | .sysfs_ops = &orangefs_sysfs_ops, |
| 977 | .default_groups = capcache_orangefs_default_groups, | 1003 | .default_groups = capcache_orangefs_default_groups, |
| 1004 | .release = capcache_orangefs_obj_release, | ||
| 978 | }; | 1005 | }; |
| 979 | 1006 | ||
| 980 | static struct orangefs_attribute ccache_hard_limit_attribute = | 1007 | static struct orangefs_attribute ccache_hard_limit_attribute = |
| @@ -1010,9 +1037,18 @@ static struct attribute *ccache_orangefs_default_attrs[] = { · 29 unmodified lines | |||
| 1010 | }; | 1037 | }; |
| 1011 | ATTRIBUTE_GROUPS(ccache_orangefs_default); | 1038 | ATTRIBUTE_GROUPS(ccache_orangefs_default); |
| 1012 | 1039 | ||
| 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 | |||
| 1013 | static struct kobj_type ccache_orangefs_ktype = { | 1048 | static struct kobj_type ccache_orangefs_ktype = { |
| 1014 | .sysfs_ops = &orangefs_sysfs_ops, | 1049 | .sysfs_ops = &orangefs_sysfs_ops, |
| 1015 | .default_groups = ccache_orangefs_default_groups, | 1050 | .default_groups = ccache_orangefs_default_groups, |
| 1051 | .release = ccache_orangefs_obj_release, | ||
| 1016 | }; | 1052 | }; |
| 1017 | 1053 | ||
| 1018 | static struct orangefs_attribute ncache_hard_limit_attribute = | 1054 | static struct orangefs_attribute ncache_hard_limit_attribute = |
| @@ -1048,9 +1084,18 @@ static struct attribute *ncache_orangefs_default_attrs[] = { · 29 unmodified lines | |||
| 1048 | }; | 1084 | }; |
| 1049 | ATTRIBUTE_GROUPS(ncache_orangefs_default); | 1085 | ATTRIBUTE_GROUPS(ncache_orangefs_default); |
| 1050 | 1086 | ||
| 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 | |||
| 1051 | static struct kobj_type ncache_orangefs_ktype = { | 1095 | static struct kobj_type ncache_orangefs_ktype = { |
| 1052 | .sysfs_ops = &orangefs_sysfs_ops, | 1096 | .sysfs_ops = &orangefs_sysfs_ops, |
| 1053 | .default_groups = ncache_orangefs_default_groups, | 1097 | .default_groups = ncache_orangefs_default_groups, |
| 1098 | .release = ncache_orangefs_obj_release, | ||
| 1054 | }; | 1099 | }; |
| 1055 | 1100 | ||
| 1056 | static struct orangefs_attribute pc_acache_attribute = | 1101 | static struct orangefs_attribute pc_acache_attribute = |
| @@ -1079,9 +1124,18 @@ static struct attribute *pc_orangefs_default_attrs[] = { · 22 unmodified lines | |||
| 1079 | }; | 1124 | }; |
| 1080 | ATTRIBUTE_GROUPS(pc_orangefs_default); | 1125 | ATTRIBUTE_GROUPS(pc_orangefs_default); |
| 1081 | 1126 | ||
| 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 | |||
| 1082 | static struct kobj_type pc_orangefs_ktype = { | 1135 | static struct kobj_type pc_orangefs_ktype = { |
| 1083 | .sysfs_ops = &orangefs_sysfs_ops, | 1136 | .sysfs_ops = &orangefs_sysfs_ops, |
| 1084 | .default_groups = pc_orangefs_default_groups, | 1137 | .default_groups = pc_orangefs_default_groups, |
| 1138 | .release = pc_orangefs_obj_release, | ||
| 1085 | }; | 1139 | }; |
| 1086 | 1140 | ||
| 1087 | static struct orangefs_attribute stats_reads_attribute = | 1141 | static struct orangefs_attribute stats_reads_attribute = |
| @@ -1103,19 +1157,20 @@ static struct attribute *stats_orangefs_default_attrs[] = { · 15 unmodified lines | |||
| 1103 | }; | 1157 | }; |
| 1104 | ATTRIBUTE_GROUPS(stats_orangefs_default); | 1158 | ATTRIBUTE_GROUPS(stats_orangefs_default); |
| 1105 | 1159 | ||
| 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 | |||
| 1106 | static struct kobj_type stats_orangefs_ktype = { | 1168 | static struct kobj_type stats_orangefs_ktype = { |
| 1107 | .sysfs_ops = &orangefs_sysfs_ops, | 1169 | .sysfs_ops = &orangefs_sysfs_ops, |
| 1108 | .default_groups = stats_orangefs_default_groups, | 1170 | .default_groups = stats_orangefs_default_groups, |
| 1171 | .release = stats_orangefs_obj_release, | ||
| 1109 | }; | 1172 | }; |
| 1110 | 1173 | ||
| 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 | |||
| 1119 | int orangefs_sysfs_init(void) | 1174 | int orangefs_sysfs_init(void) |
| 1120 | { | 1175 | { |
| 1121 | int rc = -EINVAL; | 1176 | int rc = -EINVAL; |