From: Bixuan Cui <cuibixuan@huawei.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: <linux-next@vger.kernel.org>, <gustavoars@kernel.org>,
<gregkh@linuxfoundation.org>, <linux-kernel@vger.kernel.org>,
<linux-usb@vger.kernel.org>, <qiang.zhang@windriver.com>,
"Wanghui (John)" <john.wanghui@huawei.com>
Subject: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue
Date: Fri, 17 Jul 2020 08:22:53 +0800 [thread overview]
Message-ID: <ffa85702-86ab-48d7-4da2-2efcc94b05d3@huawei.com> (raw)
In-Reply-To: <20200716154510.GE1112537@rowland.harvard.edu>
Fix the warning: [-Werror=-Wframe-larger-than=]
drivers/usb/misc/usbtest.c: In function 'test_queue':
drivers/usb/misc/usbtest.c:2148:1:
warning: the frame size of 1232 bytes is larger than 1024 bytes
Reported-by: kbuild test robot <lkp@intel.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Bixuan Cui <cuibixuan@huawei.com>
---
v2: Change MAX_SGLEN to param->sglen.
drivers/usb/misc/usbtest.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 8b220d56647b..150090ee4ec1 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -2043,7 +2043,7 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
unsigned i;
unsigned long packets = 0;
int status = 0;
- struct urb *urbs[MAX_SGLEN];
+ struct urb **urbs;
if (!param->sglen || param->iterations > UINT_MAX / param->sglen)
return -EINVAL;
@@ -2051,6 +2051,10 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
if (param->sglen > MAX_SGLEN)
return -EINVAL;
+ urbs = kcalloc(param->sglen, sizeof(*urbs), GFP_KERNEL);
+ if (!urbs)
+ return -ENOMEM;
+
memset(&context, 0, sizeof(context));
context.count = param->iterations * param->sglen;
context.dev = dev;
@@ -2137,6 +2141,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
else if (context.errors >
(context.is_iso ? context.packet_count / 10 : 0))
status = -EIO;
+
+ kfree(urbs);
return status;
fail:
@@ -2144,6 +2150,8 @@ test_queue(struct usbtest_dev *dev, struct usbtest_param_32 *param,
if (urbs[i])
simple_free_urb(urbs[i]);
}
+
+ kfree(urbs);
return status;
}
--
2.17.1
.
prev parent reply other threads:[~2020-07-17 0:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 8:27 [PATCH] usb: usbtest: reduce stack usage in test_queue Bixuan Cui
2020-07-16 13:47 ` [PATCH -next v2] " Bixuan Cui
2020-07-16 14:26 ` Greg KH
2020-07-17 0:25 ` Bixuan Cui
2020-07-16 15:45 ` Alan Stern
2020-07-17 0:22 ` Bixuan Cui
2020-07-17 0:22 ` Bixuan Cui [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ffa85702-86ab-48d7-4da2-2efcc94b05d3@huawei.com \
--to=cuibixuan@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavoars@kernel.org \
--cc=john.wanghui@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=qiang.zhang@windriver.com \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).