Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7237e22 authored by Jon Mason's avatar Jon Mason Committed by Greg Kroah-Hartman
Browse files

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: default avatarJon Mason <jon.mason@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f766755c
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -368,10 +368,14 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
			    loff_t *offp)
			    loff_t *offp)
{
{
	struct ntb_transport_qp *qp;
	struct ntb_transport_qp *qp;
	char buf[1024];
	char *buf;
	ssize_t ret, out_offset, out_count;
	ssize_t ret, out_offset, out_count;


	out_count = 1024;
	out_count = 600;

	buf = kmalloc(out_count, GFP_KERNEL);
	if (!buf)
		return -ENOMEM;


	qp = filp->private_data;
	qp = filp->private_data;
	out_offset = 0;
	out_offset = 0;
@@ -410,10 +414,13 @@ static ssize_t debugfs_read(struct file *filp, char __user *ubuf, size_t count,
			       "tx_mw_end - \t%p\n", qp->tx_mw_end);
			       "tx_mw_end - \t%p\n", qp->tx_mw_end);


	out_offset += snprintf(buf + out_offset, out_count - out_offset,
	out_offset += snprintf(buf + out_offset, out_count - out_offset,
			       "QP Link %s\n", (qp->qp_link == NTB_LINK_UP) ?
			       "\nQP Link %s\n", (qp->qp_link == NTB_LINK_UP) ?
			       "Up" : "Down");
			       "Up" : "Down");
	if (out_offset > out_count)
		out_offset = out_count;


	ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
	ret = simple_read_from_buffer(ubuf, count, offp, buf, out_offset);
	kfree(buf);
	return ret;
	return ret;
}
}