Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1597829ybh; Thu, 16 Jul 2020 17:23:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKb97yalrRV/5Ao9LFyQ4uqm7dz4P8Ixa6FteTijDECOQHYrbQuxAIhegT45kAEiXAzBuY X-Received: by 2002:a17:907:94ca:: with SMTP id dn10mr6070748ejc.348.1594945410338; Thu, 16 Jul 2020 17:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594945410; cv=none; d=google.com; s=arc-20160816; b=fhNjqv1ZZnLPC9UtB8qT4PT6tFJ07ejMdsY8BMW8vJ5ThNZpZTKq86Tp4d+Be9JQED WmiaHq9qG7cpRzuDresExAIR7iqiMEXXbWFDnF2byqZbicpT49pybSxcLmkEMJ8W23M0 izRkLW3VGNQqVfYc6v63SV7qZZJK/59qupS8xIOoP1oZnc3EmJ+v+KL46Yt6HMeR7m/6 +lTmMAaxYe3aaZ50LfHK5LL6rhP3G5demKsUypDzL4O7wCKAdxwsQju4xJQrI1nBUAF5 /bss3l3qYVzFnur9N/YFIp7U+R2qMhH8wyyDM3Q5OHDY2Hvr1ORwy1C6PSnswsxM619w WJXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=eQpZAOIp2DkFTQ+NDQHKPBsV+tBMB4Pul8FcR+wrFXg=; b=DOtHrGHGUSp8lJf+YpeT2a2k964vmOig4dWY/STkqZ12SfI0J0FtXY24x5QhcelFqQ WTo9/m+fZN0txEzDt+zDWyj37VIO8G6t+4KuNgW1vpgReXcDSeWAx3baEPbH9FrW55l9 OGCMxoDiDpxrtC9lWX3FJFmQxtAvVXyAyyaktPVw5XmxC+12hEjyQzdySE4FfmKb2plG nNsJ6ufOfEJrHWhmKtXAtO25dPAVBVWFa0SK9GZHztbr13K0veexweIHmf5J3d6iBI5T iPBo5Z/84w+gyGWhCw6peuwRHeGJIcRJivhFOv2ighjxem0eJzx9HKrvQMLgerrCSux7 VDqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i16si4122801eds.541.2020.07.16.17.23.07; Thu, 16 Jul 2020 17:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726394AbgGQAWf (ORCPT + 99 others); Thu, 16 Jul 2020 20:22:35 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:7772 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726125AbgGQAWf (ORCPT ); Thu, 16 Jul 2020 20:22:35 -0400 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 5CA266E5D3DBC4F29409; Fri, 17 Jul 2020 08:22:32 +0800 (CST) Received: from [127.0.0.1] (10.174.179.238) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Fri, 17 Jul 2020 08:22:23 +0800 Subject: Re: [PATCH -next v2] usb: usbtest: reduce stack usage in test_queue To: Alan Stern CC: , , , , , , "Wanghui (John)" References: <20200716082735.66342-1-cuibixuan@huawei.com> <42fe1a83-38a5-816b-9258-8a344008f398@huawei.com> <20200716154510.GE1112537@rowland.harvard.edu> From: Bixuan Cui Message-ID: <3c01b28e-0568-b5d6-e8ce-9176da09466c@huawei.com> Date: Fri, 17 Jul 2020 08:22:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20200716154510.GE1112537@rowland.harvard.edu> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.238] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Acked-by: Alan Stern Signed-off-by: Bixuan Cui --- 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 .