diff options
author | Jon Mason <jon.mason@intel.com> | 2013-01-19 04:02:25 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-01-20 18:45:51 -0500 |
commit | d7237e22bbcffc3237a234fdf165fde4c2b0a22d (patch) | |
tree | 6e8eedf9be954585dd4da0dea6b1e6c958d121d6 | |
parent | f766755c3057c36dc0796d2b0c633611dde6eccf (diff) |
NTB: correct stack usage warning in debugfs_read
Correct gcc warning of using too much stack debugfs_read. This is done
by kmallocing the buffer instead of using the char array on stack.
Also, shrinking the buffer to something closer to what is currently
being used.
Signed-off-by: Jon Mason <jon.mason@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/ntb/ntb_transport.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index e11b57e1939c..1bed1ba2fe5e 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
@@ -368,10 +368,14 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, | |||
368 | loff_t *offp) | 368 | loff_t *offp) |
369 | { | 369 | { |
370 | struct ntb_transport_qp *qp; | 370 | struct ntb_transport_qp *qp; |
371 | char buf[1024]; | 371 | char *buf; |
372 | ssize_t ret, out_offset, out_count; | 372 | ssize_t ret, out_offset, out_count; |
373 | 373 | ||
374 | out_count = 1024; | 374 | out_count = 600; |
375 | |||
376 | buf = kmalloc(out_count, GFP_KERNEL); | ||
377 | if (!buf) | ||
378 | return -ENOMEM; | ||
375 | 379 | ||
376 | qp = filp->private_data; | 380 | qp = filp->private_data; |
377 | out_offset = 0; | 381 | out_offset = 0; |
@@ -410,10 +414,13 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count, | |||
410 | "tx_mw_end - \t%p\n", qp->tx_mw_end); | 414 | "tx_mw_end - \t%p\n", qp->tx_mw_end); |
411 | 415 | ||
412 | out_offset += snprintf(buf + out_offset, out_count - out_offset, | 416 | out_offset += snprintf(buf + out_offset, out_count - out_offset, |
413 | "QP Link %s\n", (qp->qp_link == NTB_LINK_UP) ? | 417 | "\nQP Link %s\n", (qp->qp_link == NTB_LINK_UP) ? |
414 | "Up" : "Down"); | 418 | "Up" : "Down"); |
419 | if (out_offset > out_count) | ||
420 | out_offset = out_count; | ||
415 | 421 | ||
416 | ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset); | 422 | ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset); |
423 | kfree(buf); | ||
417 | return ret; | 424 | return ret; |
418 | } | 425 | } |
419 | 426 | ||