aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-01-08 20:19:38 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-01-09 09:41:56 -0500
commitb9c4b8a15aa54be5adeb725f2680d626a22aa9fe (patch)
treeae3cd8be6788d9dd4d69a7cb890190c1835900a9
parent3872fb73cabdd47fd4abf7b6eff21d06e57297eb (diff)
staging: lustre: lnet: selftest: don't allocate small strings.
All of the "name" buffers here are at most LST_NAME_SIZE+1 bytes, so 33 bytes at most. They are only used temporarily during the life of the function that allocates them. So it is much simpler to just allocate on the stack. Worst case is lst_tet_add_ioct(), which allocates 3 for these which 99 bytes on the stack, instead of the 24 that would have been allocated for 64-bit pointers. Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/lustre/lnet/selftest/conctl.c180
1 files changed, 29 insertions, 151 deletions
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c
index 082c0afacf23..442a18ddd41f 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -45,7 +45,7 @@
45static int 45static int
46lst_session_new_ioctl(struct lstio_session_new_args *args) 46lst_session_new_ioctl(struct lstio_session_new_args *args)
47{ 47{
48 char *name; 48 char name[LST_NAME_SIZE + 1];
49 int rc; 49 int rc;
50 50
51 if (!args->lstio_ses_idp || /* address for output sid */ 51 if (!args->lstio_ses_idp || /* address for output sid */
@@ -55,13 +55,8 @@ lst_session_new_ioctl(struct lstio_session_new_args *args)
55 args->lstio_ses_nmlen > LST_NAME_SIZE) 55 args->lstio_ses_nmlen > LST_NAME_SIZE)
56 return -EINVAL; 56 return -EINVAL;
57 57
58 LIBCFS_ALLOC(name, args->lstio_ses_nmlen + 1);
59 if (!name)
60 return -ENOMEM;
61
62 if (copy_from_user(name, args->lstio_ses_namep, 58 if (copy_from_user(name, args->lstio_ses_namep,
63 args->lstio_ses_nmlen)) { 59 args->lstio_ses_nmlen)) {
64 LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
65 return -EFAULT; 60 return -EFAULT;
66 } 61 }
67 62
@@ -74,7 +69,6 @@ lst_session_new_ioctl(struct lstio_session_new_args *args)
74 args->lstio_ses_force, 69 args->lstio_ses_force,
75 args->lstio_ses_idp); 70 args->lstio_ses_idp);
76 71
77 LIBCFS_FREE(name, args->lstio_ses_nmlen + 1);
78 return rc; 72 return rc;
79} 73}
80 74
@@ -112,7 +106,7 @@ lst_session_info_ioctl(struct lstio_session_info_args *args)
112static int 106static int
113lst_debug_ioctl(struct lstio_debug_args *args) 107lst_debug_ioctl(struct lstio_debug_args *args)
114{ 108{
115 char *name = NULL; 109 char name[LST_NAME_SIZE + 1];
116 int client = 1; 110 int client = 1;
117 int rc; 111 int rc;
118 112
@@ -128,16 +122,10 @@ lst_debug_ioctl(struct lstio_debug_args *args)
128 return -EINVAL; 122 return -EINVAL;
129 123
130 if (args->lstio_dbg_namep) { 124 if (args->lstio_dbg_namep) {
131 LIBCFS_ALLOC(name, args->lstio_dbg_nmlen + 1);
132 if (!name)
133 return -ENOMEM;
134 125
135 if (copy_from_user(name, args->lstio_dbg_namep, 126 if (copy_from_user(name, args->lstio_dbg_namep,
136 args->lstio_dbg_nmlen)) { 127 args->lstio_dbg_nmlen))
137 LIBCFS_FREE(name, args->lstio_dbg_nmlen + 1);
138
139 return -EFAULT; 128 return -EFAULT;
140 }
141 129
142 name[args->lstio_dbg_nmlen] = 0; 130 name[args->lstio_dbg_nmlen] = 0;
143 } 131 }
@@ -154,7 +142,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
154 client = 0; 142 client = 0;
155 /* fall through */ 143 /* fall through */
156 case LST_OPC_BATCHCLI: 144 case LST_OPC_BATCHCLI:
157 if (!name) 145 if (!args->lstio_dbg_namep)
158 goto out; 146 goto out;
159 147
160 rc = lstcon_batch_debug(args->lstio_dbg_timeout, 148 rc = lstcon_batch_debug(args->lstio_dbg_timeout,
@@ -162,7 +150,7 @@ lst_debug_ioctl(struct lstio_debug_args *args)
162 break; 150 break;
163 151
164 case LST_OPC_GROUP: 152 case LST_OPC_GROUP:
165 if (!name) 153 if (!args->lstio_dbg_namep)
166 goto out; 154 goto out;
167 155
168 rc = lstcon_group_debug(args->lstio_dbg_timeout, 156 rc = lstcon_group_debug(args->lstio_dbg_timeout,
@@ -185,16 +173,13 @@ lst_debug_ioctl(struct lstio_debug_args *args)
185 } 173 }
186 174
187out: 175out:
188 if (name)
189 LIBCFS_FREE(name, args->lstio_dbg_nmlen + 1);
190
191 return rc; 176 return rc;
192} 177}
193 178
194static int 179static int
195lst_group_add_ioctl(struct lstio_group_add_args *args) 180lst_group_add_ioctl(struct lstio_group_add_args *args)
196{ 181{
197 char *name; 182 char name[LST_NAME_SIZE + 1];
198 int rc; 183 int rc;
199 184
200 if (args->lstio_grp_key != console_session.ses_key) 185 if (args->lstio_grp_key != console_session.ses_key)
@@ -205,22 +190,14 @@ lst_group_add_ioctl(struct lstio_group_add_args *args)
205 args->lstio_grp_nmlen > LST_NAME_SIZE) 190 args->lstio_grp_nmlen > LST_NAME_SIZE)
206 return -EINVAL; 191 return -EINVAL;
207 192
208 LIBCFS_ALLOC(name, args->lstio_grp_nmlen + 1);
209 if (!name)
210 return -ENOMEM;
211
212 if (copy_from_user(name, args->lstio_grp_namep, 193 if (copy_from_user(name, args->lstio_grp_namep,
213 args->lstio_grp_nmlen)) { 194 args->lstio_grp_nmlen))
214 LIBCFS_FREE(name, args->lstio_grp_nmlen);
215 return -EFAULT; 195 return -EFAULT;
216 }
217 196
218 name[args->lstio_grp_nmlen] = 0; 197 name[args->lstio_grp_nmlen] = 0;
219 198
220 rc = lstcon_group_add(name); 199 rc = lstcon_group_add(name);
221 200
222 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
223
224 return rc; 201 return rc;
225} 202}
226 203
@@ -228,7 +205,7 @@ static int
228lst_group_del_ioctl(struct lstio_group_del_args *args) 205lst_group_del_ioctl(struct lstio_group_del_args *args)
229{ 206{
230 int rc; 207 int rc;
231 char *name; 208 char name[LST_NAME_SIZE + 1];
232 209
233 if (args->lstio_grp_key != console_session.ses_key) 210 if (args->lstio_grp_key != console_session.ses_key)
234 return -EACCES; 211 return -EACCES;
@@ -238,22 +215,14 @@ lst_group_del_ioctl(struct lstio_group_del_args *args)
238 args->lstio_grp_nmlen > LST_NAME_SIZE) 215 args->lstio_grp_nmlen > LST_NAME_SIZE)
239 return -EINVAL; 216 return -EINVAL;
240 217
241 LIBCFS_ALLOC(name, args->lstio_grp_nmlen + 1);
242 if (!name)
243 return -ENOMEM;
244
245 if (copy_from_user(name, args->lstio_grp_namep, 218 if (copy_from_user(name, args->lstio_grp_namep,
246 args->lstio_grp_nmlen)) { 219 args->lstio_grp_nmlen))
247 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
248 return -EFAULT; 220 return -EFAULT;
249 }
250 221
251 name[args->lstio_grp_nmlen] = 0; 222 name[args->lstio_grp_nmlen] = 0;
252 223
253 rc = lstcon_group_del(name); 224 rc = lstcon_group_del(name);
254 225
255 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
256
257 return rc; 226 return rc;
258} 227}
259 228
@@ -261,7 +230,7 @@ static int
261lst_group_update_ioctl(struct lstio_group_update_args *args) 230lst_group_update_ioctl(struct lstio_group_update_args *args)
262{ 231{
263 int rc; 232 int rc;
264 char *name; 233 char name[LST_NAME_SIZE + 1];
265 234
266 if (args->lstio_grp_key != console_session.ses_key) 235 if (args->lstio_grp_key != console_session.ses_key)
267 return -EACCES; 236 return -EACCES;
@@ -272,15 +241,9 @@ lst_group_update_ioctl(struct lstio_group_update_args *args)
272 args->lstio_grp_nmlen > LST_NAME_SIZE) 241 args->lstio_grp_nmlen > LST_NAME_SIZE)
273 return -EINVAL; 242 return -EINVAL;
274 243
275 LIBCFS_ALLOC(name, args->lstio_grp_nmlen + 1);
276 if (!name)
277 return -ENOMEM;
278
279 if (copy_from_user(name, args->lstio_grp_namep, 244 if (copy_from_user(name, args->lstio_grp_namep,
280 args->lstio_grp_nmlen)) { 245 args->lstio_grp_nmlen))
281 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
282 return -EFAULT; 246 return -EFAULT;
283 }
284 247
285 name[args->lstio_grp_nmlen] = 0; 248 name[args->lstio_grp_nmlen] = 0;
286 249
@@ -309,8 +272,6 @@ lst_group_update_ioctl(struct lstio_group_update_args *args)
309 break; 272 break;
310 } 273 }
311 274
312 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
313
314 return rc; 275 return rc;
315} 276}
316 277
@@ -319,7 +280,7 @@ lst_nodes_add_ioctl(struct lstio_group_nodes_args *args)
319{ 280{
320 unsigned int feats; 281 unsigned int feats;
321 int rc; 282 int rc;
322 char *name; 283 char name[LST_NAME_SIZE + 1];
323 284
324 if (args->lstio_grp_key != console_session.ses_key) 285 if (args->lstio_grp_key != console_session.ses_key)
325 return -EACCES; 286 return -EACCES;
@@ -333,16 +294,9 @@ lst_nodes_add_ioctl(struct lstio_group_nodes_args *args)
333 args->lstio_grp_nmlen > LST_NAME_SIZE) 294 args->lstio_grp_nmlen > LST_NAME_SIZE)
334 return -EINVAL; 295 return -EINVAL;
335 296
336 LIBCFS_ALLOC(name, args->lstio_grp_nmlen + 1);
337 if (!name)
338 return -ENOMEM;
339
340 if (copy_from_user(name, args->lstio_grp_namep, 297 if (copy_from_user(name, args->lstio_grp_namep,
341 args->lstio_grp_nmlen)) { 298 args->lstio_grp_nmlen))
342 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
343
344 return -EFAULT; 299 return -EFAULT;
345 }
346 300
347 name[args->lstio_grp_nmlen] = 0; 301 name[args->lstio_grp_nmlen] = 0;
348 302
@@ -350,7 +304,6 @@ lst_nodes_add_ioctl(struct lstio_group_nodes_args *args)
350 args->lstio_grp_idsp, &feats, 304 args->lstio_grp_idsp, &feats,
351 args->lstio_grp_resultp); 305 args->lstio_grp_resultp);
352 306
353 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
354 if (!rc && 307 if (!rc &&
355 copy_to_user(args->lstio_grp_featp, &feats, sizeof(feats))) { 308 copy_to_user(args->lstio_grp_featp, &feats, sizeof(feats))) {
356 return -EINVAL; 309 return -EINVAL;
@@ -379,7 +332,7 @@ lst_group_list_ioctl(struct lstio_group_list_args *args)
379static int 332static int
380lst_group_info_ioctl(struct lstio_group_info_args *args) 333lst_group_info_ioctl(struct lstio_group_info_args *args)
381{ 334{
382 char *name; 335 char name[LST_NAME_SIZE + 1];
383 int ndent; 336 int ndent;
384 int index; 337 int index;
385 int rc; 338 int rc;
@@ -411,23 +364,15 @@ lst_group_info_ioctl(struct lstio_group_info_args *args)
411 return -EINVAL; 364 return -EINVAL;
412 } 365 }
413 366
414 LIBCFS_ALLOC(name, args->lstio_grp_nmlen + 1);
415 if (!name)
416 return -ENOMEM;
417
418 if (copy_from_user(name, args->lstio_grp_namep, 367 if (copy_from_user(name, args->lstio_grp_namep,
419 args->lstio_grp_nmlen)) { 368 args->lstio_grp_nmlen))
420 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
421 return -EFAULT; 369 return -EFAULT;
422 }
423 370
424 name[args->lstio_grp_nmlen] = 0; 371 name[args->lstio_grp_nmlen] = 0;
425 372
426 rc = lstcon_group_info(name, args->lstio_grp_entp, 373 rc = lstcon_group_info(name, args->lstio_grp_entp,
427 &index, &ndent, args->lstio_grp_dentsp); 374 &index, &ndent, args->lstio_grp_dentsp);
428 375
429 LIBCFS_FREE(name, args->lstio_grp_nmlen + 1);
430
431 if (rc) 376 if (rc)
432 return rc; 377 return rc;
433 378
@@ -443,7 +388,7 @@ static int
443lst_batch_add_ioctl(struct lstio_batch_add_args *args) 388lst_batch_add_ioctl(struct lstio_batch_add_args *args)
444{ 389{
445 int rc; 390 int rc;
446 char *name; 391 char name[LST_NAME_SIZE + 1];
447 392
448 if (args->lstio_bat_key != console_session.ses_key) 393 if (args->lstio_bat_key != console_session.ses_key)
449 return -EACCES; 394 return -EACCES;
@@ -453,22 +398,14 @@ lst_batch_add_ioctl(struct lstio_batch_add_args *args)
453 args->lstio_bat_nmlen > LST_NAME_SIZE) 398 args->lstio_bat_nmlen > LST_NAME_SIZE)
454 return -EINVAL; 399 return -EINVAL;
455 400
456 LIBCFS_ALLOC(name, args->lstio_bat_nmlen + 1);
457 if (!name)
458 return -ENOMEM;
459
460 if (copy_from_user(name, args->lstio_bat_namep, 401 if (copy_from_user(name, args->lstio_bat_namep,
461 args->lstio_bat_nmlen)) { 402 args->lstio_bat_nmlen))
462 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
463 return -EFAULT; 403 return -EFAULT;
464 }
465 404
466 name[args->lstio_bat_nmlen] = 0; 405 name[args->lstio_bat_nmlen] = 0;
467 406
468 rc = lstcon_batch_add(name); 407 rc = lstcon_batch_add(name);
469 408
470 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
471
472 return rc; 409 return rc;
473} 410}
474 411
@@ -476,7 +413,7 @@ static int
476lst_batch_run_ioctl(struct lstio_batch_run_args *args) 413lst_batch_run_ioctl(struct lstio_batch_run_args *args)
477{ 414{
478 int rc; 415 int rc;
479 char *name; 416 char name[LST_NAME_SIZE + 1];
480 417
481 if (args->lstio_bat_key != console_session.ses_key) 418 if (args->lstio_bat_key != console_session.ses_key)
482 return -EACCES; 419 return -EACCES;
@@ -486,23 +423,15 @@ lst_batch_run_ioctl(struct lstio_batch_run_args *args)
486 args->lstio_bat_nmlen > LST_NAME_SIZE) 423 args->lstio_bat_nmlen > LST_NAME_SIZE)
487 return -EINVAL; 424 return -EINVAL;
488 425
489 LIBCFS_ALLOC(name, args->lstio_bat_nmlen + 1);
490 if (!name)
491 return -ENOMEM;
492
493 if (copy_from_user(name, args->lstio_bat_namep, 426 if (copy_from_user(name, args->lstio_bat_namep,
494 args->lstio_bat_nmlen)) { 427 args->lstio_bat_nmlen))
495 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
496 return -EFAULT; 428 return -EFAULT;
497 }
498 429
499 name[args->lstio_bat_nmlen] = 0; 430 name[args->lstio_bat_nmlen] = 0;
500 431
501 rc = lstcon_batch_run(name, args->lstio_bat_timeout, 432 rc = lstcon_batch_run(name, args->lstio_bat_timeout,
502 args->lstio_bat_resultp); 433 args->lstio_bat_resultp);
503 434
504 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
505
506 return rc; 435 return rc;
507} 436}
508 437
@@ -510,7 +439,7 @@ static int
510lst_batch_stop_ioctl(struct lstio_batch_stop_args *args) 439lst_batch_stop_ioctl(struct lstio_batch_stop_args *args)
511{ 440{
512 int rc; 441 int rc;
513 char *name; 442 char name[LST_NAME_SIZE + 1];
514 443
515 if (args->lstio_bat_key != console_session.ses_key) 444 if (args->lstio_bat_key != console_session.ses_key)
516 return -EACCES; 445 return -EACCES;
@@ -521,30 +450,22 @@ lst_batch_stop_ioctl(struct lstio_batch_stop_args *args)
521 args->lstio_bat_nmlen > LST_NAME_SIZE) 450 args->lstio_bat_nmlen > LST_NAME_SIZE)
522 return -EINVAL; 451 return -EINVAL;
523 452
524 LIBCFS_ALLOC(name, args->lstio_bat_nmlen + 1);
525 if (!name)
526 return -ENOMEM;
527
528 if (copy_from_user(name, args->lstio_bat_namep, 453 if (copy_from_user(name, args->lstio_bat_namep,
529 args->lstio_bat_nmlen)) { 454 args->lstio_bat_nmlen))
530 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
531 return -EFAULT; 455 return -EFAULT;
532 }
533 456
534 name[args->lstio_bat_nmlen] = 0; 457 name[args->lstio_bat_nmlen] = 0;
535 458
536 rc = lstcon_batch_stop(name, args->lstio_bat_force, 459 rc = lstcon_batch_stop(name, args->lstio_bat_force,
537 args->lstio_bat_resultp); 460 args->lstio_bat_resultp);
538 461
539 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
540
541 return rc; 462 return rc;
542} 463}
543 464
544static int 465static int
545lst_batch_query_ioctl(struct lstio_batch_query_args *args) 466lst_batch_query_ioctl(struct lstio_batch_query_args *args)
546{ 467{
547 char *name; 468 char name[LST_NAME_SIZE + 1];
548 int rc; 469 int rc;
549 470
550 if (args->lstio_bat_key != console_session.ses_key) 471 if (args->lstio_bat_key != console_session.ses_key)
@@ -559,15 +480,9 @@ lst_batch_query_ioctl(struct lstio_batch_query_args *args)
559 if (args->lstio_bat_testidx < 0) 480 if (args->lstio_bat_testidx < 0)
560 return -EINVAL; 481 return -EINVAL;
561 482
562 LIBCFS_ALLOC(name, args->lstio_bat_nmlen + 1);
563 if (!name)
564 return -ENOMEM;
565
566 if (copy_from_user(name, args->lstio_bat_namep, 483 if (copy_from_user(name, args->lstio_bat_namep,
567 args->lstio_bat_nmlen)) { 484 args->lstio_bat_nmlen))
568 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
569 return -EFAULT; 485 return -EFAULT;
570 }
571 486
572 name[args->lstio_bat_nmlen] = 0; 487 name[args->lstio_bat_nmlen] = 0;
573 488
@@ -577,8 +492,6 @@ lst_batch_query_ioctl(struct lstio_batch_query_args *args)
577 args->lstio_bat_timeout, 492 args->lstio_bat_timeout,
578 args->lstio_bat_resultp); 493 args->lstio_bat_resultp);
579 494
580 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
581
582 return rc; 495 return rc;
583} 496}
584 497
@@ -602,7 +515,7 @@ lst_batch_list_ioctl(struct lstio_batch_list_args *args)
602static int 515static int
603lst_batch_info_ioctl(struct lstio_batch_info_args *args) 516lst_batch_info_ioctl(struct lstio_batch_info_args *args)
604{ 517{
605 char *name; 518 char name[LST_NAME_SIZE + 1];
606 int rc; 519 int rc;
607 int index; 520 int index;
608 int ndent; 521 int ndent;
@@ -634,15 +547,9 @@ lst_batch_info_ioctl(struct lstio_batch_info_args *args)
634 return -EINVAL; 547 return -EINVAL;
635 } 548 }
636 549
637 LIBCFS_ALLOC(name, args->lstio_bat_nmlen + 1);
638 if (!name)
639 return -ENOMEM;
640
641 if (copy_from_user(name, args->lstio_bat_namep, 550 if (copy_from_user(name, args->lstio_bat_namep,
642 args->lstio_bat_nmlen)) { 551 args->lstio_bat_nmlen))
643 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
644 return -EFAULT; 552 return -EFAULT;
645 }
646 553
647 name[args->lstio_bat_nmlen] = 0; 554 name[args->lstio_bat_nmlen] = 0;
648 555
@@ -650,8 +557,6 @@ lst_batch_info_ioctl(struct lstio_batch_info_args *args)
650 args->lstio_bat_server, args->lstio_bat_testidx, 557 args->lstio_bat_server, args->lstio_bat_testidx,
651 &index, &ndent, args->lstio_bat_dentsp); 558 &index, &ndent, args->lstio_bat_dentsp);
652 559
653 LIBCFS_FREE(name, args->lstio_bat_nmlen + 1);
654
655 if (rc) 560 if (rc)
656 return rc; 561 return rc;
657 562
@@ -667,7 +572,7 @@ static int
667lst_stat_query_ioctl(struct lstio_stat_args *args) 572lst_stat_query_ioctl(struct lstio_stat_args *args)
668{ 573{
669 int rc; 574 int rc;
670 char *name = NULL; 575 char name[LST_NAME_SIZE + 1];
671 576
672 /* TODO: not finished */ 577 /* TODO: not finished */
673 if (args->lstio_sta_key != console_session.ses_key) 578 if (args->lstio_sta_key != console_session.ses_key)
@@ -689,10 +594,6 @@ lst_stat_query_ioctl(struct lstio_stat_args *args)
689 args->lstio_sta_nmlen > LST_NAME_SIZE) 594 args->lstio_sta_nmlen > LST_NAME_SIZE)
690 return -EINVAL; 595 return -EINVAL;
691 596
692 LIBCFS_ALLOC(name, args->lstio_sta_nmlen + 1);
693 if (!name)
694 return -ENOMEM;
695
696 rc = copy_from_user(name, args->lstio_sta_namep, 597 rc = copy_from_user(name, args->lstio_sta_namep,
697 args->lstio_sta_nmlen); 598 args->lstio_sta_nmlen);
698 if (!rc) 599 if (!rc)
@@ -704,16 +605,14 @@ lst_stat_query_ioctl(struct lstio_stat_args *args)
704 rc = -EINVAL; 605 rc = -EINVAL;
705 } 606 }
706 607
707 if (name)
708 LIBCFS_FREE(name, args->lstio_sta_nmlen + 1);
709 return rc; 608 return rc;
710} 609}
711 610
712static int lst_test_add_ioctl(struct lstio_test_args *args) 611static int lst_test_add_ioctl(struct lstio_test_args *args)
713{ 612{
714 char *batch_name; 613 char batch_name[LST_NAME_SIZE + 1];
715 char *src_name = NULL; 614 char src_name[LST_NAME_SIZE + 1];
716 char *dst_name = NULL; 615 char dst_name[LST_NAME_SIZE + 1];
717 void *param = NULL; 616 void *param = NULL;
718 int ret = 0; 617 int ret = 0;
719 int rc = -ENOMEM; 618 int rc = -ENOMEM;
@@ -748,18 +647,6 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
748 if (!args->lstio_tes_param && args->lstio_tes_param_len) 647 if (!args->lstio_tes_param && args->lstio_tes_param_len)
749 return -EINVAL; 648 return -EINVAL;
750 649
751 LIBCFS_ALLOC(batch_name, args->lstio_tes_bat_nmlen + 1);
752 if (!batch_name)
753 return rc;
754
755 LIBCFS_ALLOC(src_name, args->lstio_tes_sgrp_nmlen + 1);
756 if (!src_name)
757 goto out;
758
759 LIBCFS_ALLOC(dst_name, args->lstio_tes_dgrp_nmlen + 1);
760 if (!dst_name)
761 goto out;
762
763 if (args->lstio_tes_param) { 650 if (args->lstio_tes_param) {
764 LIBCFS_ALLOC(param, args->lstio_tes_param_len); 651 LIBCFS_ALLOC(param, args->lstio_tes_param_len);
765 if (!param) 652 if (!param)
@@ -791,15 +678,6 @@ static int lst_test_add_ioctl(struct lstio_test_args *args)
791 rc = (copy_to_user(args->lstio_tes_retp, &ret, 678 rc = (copy_to_user(args->lstio_tes_retp, &ret,
792 sizeof(ret))) ? -EFAULT : 0; 679 sizeof(ret))) ? -EFAULT : 0;
793out: 680out:
794 if (batch_name)
795 LIBCFS_FREE(batch_name, args->lstio_tes_bat_nmlen + 1);
796
797 if (src_name)
798 LIBCFS_FREE(src_name, args->lstio_tes_sgrp_nmlen + 1);
799
800 if (dst_name)
801 LIBCFS_FREE(dst_name, args->lstio_tes_dgrp_nmlen + 1);
802
803 if (param) 681 if (param)
804 LIBCFS_FREE(param, args->lstio_tes_param_len); 682 LIBCFS_FREE(param, args->lstio_tes_param_len);
805 683