.. | .. |
---|
64 | 64 | __u64 mask2; |
---|
65 | 65 | }; |
---|
66 | 66 | |
---|
67 | | -static int orangefs_kernel_debug_init(void); |
---|
| 67 | +static void orangefs_kernel_debug_init(void); |
---|
68 | 68 | |
---|
69 | 69 | static int orangefs_debug_help_open(struct inode *, struct file *); |
---|
70 | 70 | static void *help_start(struct seq_file *, loff_t *); |
---|
.. | .. |
---|
99 | 99 | static char client_debug_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; |
---|
100 | 100 | static char client_debug_array_string[ORANGEFS_MAX_DEBUG_STRING_LEN]; |
---|
101 | 101 | |
---|
102 | | -static struct dentry *help_file_dentry; |
---|
103 | 102 | static struct dentry *client_debug_dentry; |
---|
104 | 103 | static struct dentry *debug_dir; |
---|
105 | 104 | |
---|
.. | .. |
---|
151 | 150 | * initialize kmod debug operations, create orangefs debugfs dir and |
---|
152 | 151 | * ORANGEFS_KMOD_DEBUG_HELP_FILE. |
---|
153 | 152 | */ |
---|
154 | | -int orangefs_debugfs_init(int debug_mask) |
---|
| 153 | +void orangefs_debugfs_init(int debug_mask) |
---|
155 | 154 | { |
---|
156 | | - int rc = -ENOMEM; |
---|
157 | | - |
---|
158 | 155 | /* convert input debug mask to a 64-bit unsigned integer */ |
---|
159 | 156 | orangefs_gossip_debug_mask = (unsigned long long)debug_mask; |
---|
160 | 157 | |
---|
.. | .. |
---|
183 | 180 | (unsigned long long)orangefs_gossip_debug_mask); |
---|
184 | 181 | |
---|
185 | 182 | debug_dir = debugfs_create_dir("orangefs", NULL); |
---|
186 | | - if (!debug_dir) { |
---|
187 | | - pr_info("%s: debugfs_create_dir failed.\n", __func__); |
---|
188 | | - goto out; |
---|
189 | | - } |
---|
190 | 183 | |
---|
191 | | - help_file_dentry = debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE, |
---|
192 | | - 0444, |
---|
193 | | - debug_dir, |
---|
194 | | - debug_help_string, |
---|
195 | | - &debug_help_fops); |
---|
196 | | - if (!help_file_dentry) { |
---|
197 | | - pr_info("%s: debugfs_create_file failed.\n", __func__); |
---|
198 | | - goto out; |
---|
199 | | - } |
---|
| 184 | + debugfs_create_file(ORANGEFS_KMOD_DEBUG_HELP_FILE, 0444, debug_dir, |
---|
| 185 | + debug_help_string, &debug_help_fops); |
---|
200 | 186 | |
---|
201 | 187 | orangefs_debug_disabled = 0; |
---|
202 | 188 | |
---|
203 | | - rc = orangefs_kernel_debug_init(); |
---|
204 | | - |
---|
205 | | -out: |
---|
206 | | - |
---|
207 | | - return rc; |
---|
| 189 | + orangefs_kernel_debug_init(); |
---|
208 | 190 | } |
---|
209 | 191 | |
---|
210 | 192 | /* |
---|
211 | 193 | * initialize the kernel-debug file. |
---|
212 | 194 | */ |
---|
213 | | -static int orangefs_kernel_debug_init(void) |
---|
| 195 | +static void orangefs_kernel_debug_init(void) |
---|
214 | 196 | { |
---|
215 | | - int rc = -ENOMEM; |
---|
216 | | - struct dentry *ret; |
---|
217 | | - char *k_buffer = NULL; |
---|
| 197 | + static char k_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; |
---|
218 | 198 | |
---|
219 | 199 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); |
---|
220 | | - |
---|
221 | | - k_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); |
---|
222 | | - if (!k_buffer) |
---|
223 | | - goto out; |
---|
224 | 200 | |
---|
225 | 201 | if (strlen(kernel_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { |
---|
226 | 202 | strcpy(k_buffer, kernel_debug_string); |
---|
.. | .. |
---|
230 | 206 | pr_info("%s: overflow 1!\n", __func__); |
---|
231 | 207 | } |
---|
232 | 208 | |
---|
233 | | - ret = debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, |
---|
234 | | - 0444, |
---|
235 | | - debug_dir, |
---|
236 | | - k_buffer, |
---|
237 | | - &kernel_debug_fops); |
---|
238 | | - if (!ret) { |
---|
239 | | - pr_info("%s: failed to create %s.\n", |
---|
240 | | - __func__, |
---|
241 | | - ORANGEFS_KMOD_DEBUG_FILE); |
---|
242 | | - goto out; |
---|
243 | | - } |
---|
244 | | - |
---|
245 | | - rc = 0; |
---|
246 | | - |
---|
247 | | -out: |
---|
248 | | - |
---|
249 | | - gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); |
---|
250 | | - return rc; |
---|
| 209 | + debugfs_create_file(ORANGEFS_KMOD_DEBUG_FILE, 0444, debug_dir, k_buffer, |
---|
| 210 | + &kernel_debug_fops); |
---|
251 | 211 | } |
---|
252 | 212 | |
---|
253 | 213 | |
---|
254 | 214 | void orangefs_debugfs_cleanup(void) |
---|
255 | 215 | { |
---|
256 | 216 | debugfs_remove_recursive(debug_dir); |
---|
| 217 | + kfree(debug_help_string); |
---|
| 218 | + debug_help_string = NULL; |
---|
257 | 219 | } |
---|
258 | 220 | |
---|
259 | 221 | /* open ORANGEFS_KMOD_DEBUG_HELP_FILE */ |
---|
.. | .. |
---|
329 | 291 | /* |
---|
330 | 292 | * initialize the client-debug file. |
---|
331 | 293 | */ |
---|
332 | | -static int orangefs_client_debug_init(void) |
---|
| 294 | +static void orangefs_client_debug_init(void) |
---|
333 | 295 | { |
---|
334 | 296 | |
---|
335 | | - int rc = -ENOMEM; |
---|
336 | | - char *c_buffer = NULL; |
---|
| 297 | + static char c_buffer[ORANGEFS_MAX_DEBUG_STRING_LEN] = { }; |
---|
337 | 298 | |
---|
338 | 299 | gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: start\n", __func__); |
---|
339 | | - |
---|
340 | | - c_buffer = kzalloc(ORANGEFS_MAX_DEBUG_STRING_LEN, GFP_KERNEL); |
---|
341 | | - if (!c_buffer) |
---|
342 | | - goto out; |
---|
343 | 300 | |
---|
344 | 301 | if (strlen(client_debug_string) + 1 < ORANGEFS_MAX_DEBUG_STRING_LEN) { |
---|
345 | 302 | strcpy(c_buffer, client_debug_string); |
---|
.. | .. |
---|
354 | 311 | debug_dir, |
---|
355 | 312 | c_buffer, |
---|
356 | 313 | &kernel_debug_fops); |
---|
357 | | - if (!client_debug_dentry) { |
---|
358 | | - pr_info("%s: failed to create updated %s.\n", |
---|
359 | | - __func__, |
---|
360 | | - ORANGEFS_CLIENT_DEBUG_FILE); |
---|
361 | | - goto out; |
---|
362 | | - } |
---|
363 | | - |
---|
364 | | - rc = 0; |
---|
365 | | - |
---|
366 | | -out: |
---|
367 | | - |
---|
368 | | - gossip_debug(GOSSIP_DEBUGFS_DEBUG, "%s: rc:%d:\n", __func__, rc); |
---|
369 | | - return rc; |
---|
370 | 314 | } |
---|
371 | 315 | |
---|
372 | 316 | /* open ORANGEFS_KMOD_DEBUG_FILE or ORANGEFS_CLIENT_DEBUG_FILE.*/ |
---|
.. | .. |
---|
709 | 653 | memset(debug_help_string, 0, DEBUG_HELP_STRING_SIZE); |
---|
710 | 654 | strlcat(debug_help_string, new, string_size); |
---|
711 | 655 | mutex_unlock(&orangefs_help_file_lock); |
---|
| 656 | + kfree(new); |
---|
712 | 657 | } |
---|
713 | 658 | |
---|
714 | 659 | rc = 0; |
---|
.. | .. |
---|
964 | 909 | return ret; |
---|
965 | 910 | } |
---|
966 | 911 | |
---|
967 | | -int orangefs_debugfs_new_client_string(void __user *arg) |
---|
| 912 | +int orangefs_debugfs_new_client_string(void __user *arg) |
---|
968 | 913 | { |
---|
969 | 914 | int ret; |
---|
970 | 915 | |
---|
.. | .. |
---|
1017 | 962 | return 0; |
---|
1018 | 963 | } |
---|
1019 | 964 | |
---|
1020 | | -int orangefs_debugfs_new_debug(void __user *arg) |
---|
| 965 | +int orangefs_debugfs_new_debug(void __user *arg) |
---|
1021 | 966 | { |
---|
1022 | 967 | struct dev_mask_info_s mask_info = {0}; |
---|
1023 | 968 | int ret; |
---|