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
commit2aa8b1b728da158d8c55f0bd589468183e7865c1 (patch)
tree3ebe18aa40169ca92faec305926da86c7fe65e3e
parentb9c4b8a15aa54be5adeb725f2680d626a22aa9fe (diff)
staging: lustre: lnet: use kmalloc/kvmalloc in router_proc
The buffers allocated in router_proc are to temporarily hold strings created for procfs files. So they do not need to be zeroed and are safe to use GFP_KERNEL. So use kmalloc() directly except in two cases where it isn't trivial to confirm that the size is always small. In those cases, use kvmalloc(). Signed-off-by: NeilBrown <neilb@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/lustre/lnet/lnet/router_proc.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index 43038f930ba1..1a71ffebc889 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -95,7 +95,7 @@ static int __proc_lnet_stats(void *data, int write,
95 if (!ctrs) 95 if (!ctrs)
96 return -ENOMEM; 96 return -ENOMEM;
97 97
98 LIBCFS_ALLOC(tmpstr, tmpsiz); 98 tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
99 if (!tmpstr) { 99 if (!tmpstr) {
100 kfree(ctrs); 100 kfree(ctrs);
101 return -ENOMEM; 101 return -ENOMEM;
@@ -118,7 +118,7 @@ static int __proc_lnet_stats(void *data, int write,
118 rc = cfs_trace_copyout_string(buffer, nob, 118 rc = cfs_trace_copyout_string(buffer, nob,
119 tmpstr + pos, "\n"); 119 tmpstr + pos, "\n");
120 120
121 LIBCFS_FREE(tmpstr, tmpsiz); 121 kfree(tmpstr);
122 kfree(ctrs); 122 kfree(ctrs);
123 return rc; 123 return rc;
124} 124}
@@ -151,7 +151,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
151 if (!*lenp) 151 if (!*lenp)
152 return 0; 152 return 0;
153 153
154 LIBCFS_ALLOC(tmpstr, tmpsiz); 154 tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
155 if (!tmpstr) 155 if (!tmpstr)
156 return -ENOMEM; 156 return -ENOMEM;
157 157
@@ -183,7 +183,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
183 183
184 if (ver != LNET_PROC_VERSION(the_lnet.ln_remote_nets_version)) { 184 if (ver != LNET_PROC_VERSION(the_lnet.ln_remote_nets_version)) {
185 lnet_net_unlock(0); 185 lnet_net_unlock(0);
186 LIBCFS_FREE(tmpstr, tmpsiz); 186 kfree(tmpstr);
187 return -ESTALE; 187 return -ESTALE;
188 } 188 }
189 189
@@ -248,7 +248,7 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
248 } 248 }
249 } 249 }
250 250
251 LIBCFS_FREE(tmpstr, tmpsiz); 251 kfree(tmpstr);
252 252
253 if (!rc) 253 if (!rc)
254 *lenp = len; 254 *lenp = len;
@@ -275,7 +275,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
275 if (!*lenp) 275 if (!*lenp)
276 return 0; 276 return 0;
277 277
278 LIBCFS_ALLOC(tmpstr, tmpsiz); 278 tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
279 if (!tmpstr) 279 if (!tmpstr)
280 return -ENOMEM; 280 return -ENOMEM;
281 281
@@ -303,7 +303,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
303 if (ver != LNET_PROC_VERSION(the_lnet.ln_routers_version)) { 303 if (ver != LNET_PROC_VERSION(the_lnet.ln_routers_version)) {
304 lnet_net_unlock(0); 304 lnet_net_unlock(0);
305 305
306 LIBCFS_FREE(tmpstr, tmpsiz); 306 kfree(tmpstr);
307 return -ESTALE; 307 return -ESTALE;
308 } 308 }
309 309
@@ -385,7 +385,7 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
385 } 385 }
386 } 386 }
387 387
388 LIBCFS_FREE(tmpstr, tmpsiz); 388 kfree(tmpstr);
389 389
390 if (!rc) 390 if (!rc)
391 *lenp = len; 391 *lenp = len;
@@ -418,7 +418,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
418 return 0; 418 return 0;
419 } 419 }
420 420
421 LIBCFS_ALLOC(tmpstr, tmpsiz); 421 tmpstr = kmalloc(tmpsiz, GFP_KERNEL);
422 if (!tmpstr) 422 if (!tmpstr)
423 return -ENOMEM; 423 return -ENOMEM;
424 424
@@ -448,7 +448,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
448 448
449 if (ver != LNET_PROC_VERSION(ptable->pt_version)) { 449 if (ver != LNET_PROC_VERSION(ptable->pt_version)) {
450 lnet_net_unlock(cpt); 450 lnet_net_unlock(cpt);
451 LIBCFS_FREE(tmpstr, tmpsiz); 451 kfree(tmpstr);
452 return -ESTALE; 452 return -ESTALE;
453 } 453 }
454 454
@@ -556,7 +556,7 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
556 *ppos = LNET_PROC_POS_MAKE(cpt, ver, hash, hoff); 556 *ppos = LNET_PROC_POS_MAKE(cpt, ver, hash, hoff);
557 } 557 }
558 558
559 LIBCFS_FREE(tmpstr, tmpsiz); 559 kfree(tmpstr);
560 560
561 if (!rc) 561 if (!rc)
562 *lenp = len; 562 *lenp = len;
@@ -579,7 +579,7 @@ static int __proc_lnet_buffers(void *data, int write,
579 579
580 /* (4 %d) * 4 * LNET_CPT_NUMBER */ 580 /* (4 %d) * 4 * LNET_CPT_NUMBER */
581 tmpsiz = 64 * (LNET_NRBPOOLS + 1) * LNET_CPT_NUMBER; 581 tmpsiz = 64 * (LNET_NRBPOOLS + 1) * LNET_CPT_NUMBER;
582 LIBCFS_ALLOC(tmpstr, tmpsiz); 582 tmpstr = kvmalloc(tmpsiz, GFP_KERNEL);
583 if (!tmpstr) 583 if (!tmpstr)
584 return -ENOMEM; 584 return -ENOMEM;
585 585
@@ -618,7 +618,7 @@ static int __proc_lnet_buffers(void *data, int write,
618 rc = cfs_trace_copyout_string(buffer, nob, 618 rc = cfs_trace_copyout_string(buffer, nob,
619 tmpstr + pos, NULL); 619 tmpstr + pos, NULL);
620 620
621 LIBCFS_FREE(tmpstr, tmpsiz); 621 kvfree(tmpstr);
622 return rc; 622 return rc;
623} 623}
624 624
@@ -643,7 +643,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
643 if (!*lenp) 643 if (!*lenp)
644 return 0; 644 return 0;
645 645
646 LIBCFS_ALLOC(tmpstr, tmpsiz); 646 tmpstr = kvmalloc(tmpsiz, GFP_KERNEL);
647 if (!tmpstr) 647 if (!tmpstr)
648 return -ENOMEM; 648 return -ENOMEM;
649 649
@@ -744,7 +744,7 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
744 *ppos += 1; 744 *ppos += 1;
745 } 745 }
746 746
747 LIBCFS_FREE(tmpstr, tmpsiz); 747 kvfree(tmpstr);
748 748
749 if (!rc) 749 if (!rc)
750 *lenp = len; 750 *lenp = len;
@@ -795,7 +795,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
795 int rc; 795 int rc;
796 int i; 796 int i;
797 797
798 LIBCFS_ALLOC(buf, buf_len); 798 buf = kmalloc(buf_len, GFP_KERNEL);
799 if (!buf) 799 if (!buf)
800 return -ENOMEM; 800 return -ENOMEM;
801 801
@@ -843,7 +843,7 @@ static int __proc_lnet_portal_rotor(void *data, int write,
843 } 843 }
844 lnet_res_unlock(0); 844 lnet_res_unlock(0);
845out: 845out:
846 LIBCFS_FREE(buf, buf_len); 846 kfree(buf);
847 return rc; 847 return rc;
848} 848}
849 849