Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp423021ybv; Thu, 20 Feb 2020 00:44:53 -0800 (PST) X-Google-Smtp-Source: APXvYqztPXHPPPXPEyTdkfS589/n2iWnLJGdiC+omDBN9wyQD8thlRnzfux6gJQR2TgJQzjF5p4u X-Received: by 2002:a9d:7:: with SMTP id 7mr21690618ota.26.1582188292992; Thu, 20 Feb 2020 00:44:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582188292; cv=none; d=google.com; s=arc-20160816; b=uoONrR5SF6oRRcwu33jUDL+s3cZjw0h79SCl9840lPQS7AUe4OWBTrGOieaEMYv1/i NUYWkEtPyQBJnGUsEE6fWD/OKnO9wgB7+DH5HpqNAzdBO+hZsqGIjsZ88/Pw3fkw6ILg PoOa6Efz8Af2sm/JSyQmvWXgw95/Pz2+jHHXfw2DS/yulAuQ6I/lSwCdZhOsMahZGNaX We1R/zc0fEKcDQu6caz+VwY6GE8wDy6AKes3HBQTaWhXhN2AFyyUZUs8bsD1WGBoIRsp OwyLQxHY6pYbKl7HeWxIMTZm/gnDKXeIqt+NgsnMwjI8AXvFMoH+AS/na9aKJB7vlUuc hEqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=3DBcmRHN7uJqFWQQFJU2jUM8me9GZcXg5MtIEEBW19g=; b=boT1SeD9q6//mj2z6Ew0V6DtM8DPvNjhWYnAwjLdzW870flxeUVgKurBfh3ACQVnyK 1q9+asVXmpxkCEUnE3z17SL0AIORG3KMCZtt1YDBwaxJJRfk3IgMDSbKtP2FITamzbZK gUiuVPpph8vx8/Bbo1Ku2C3ZNGqnBz5Hm8eqn67Q+jON0ey43N7JZti6SLeEm0xI3mGh fqFdjoifZpw/i/Ai3xQIm3urEw/wzP7w3KYl3g50Qyjj3hKfQb9rp4c9Z8OWqrOFAEpB gdaYMJZ8Hq4Jj2uZyIJIwkgTV7CokMnq+IRFEL/lDQsxR07y/1c/Fcm90g5sZS0ZupUr svww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=j4caedeS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x2si1385131otk.29.2020.02.20.00.44.39; Thu, 20 Feb 2020 00:44:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=j4caedeS; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726921AbgBTIn3 (ORCPT + 99 others); Thu, 20 Feb 2020 03:43:29 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:36242 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgBTIn3 (ORCPT ); Thu, 20 Feb 2020 03:43:29 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K8cv00119896; Thu, 20 Feb 2020 08:43:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=3DBcmRHN7uJqFWQQFJU2jUM8me9GZcXg5MtIEEBW19g=; b=j4caedeSclA+wC5JW86i2YTtdgvD6z7Q21bpuXdgyugzbfmGJ6PlhDKHkjWMPTezuUyA 4lUF0IJ01FpBja8+blyiBMv0tip0G6/yebcmWvfF8/qlY9sP4wQT5Op/tDr7ZnNR3BRH aKDOHjlNRAqOpdu+XN+PRUTZ3wrMr6M/aBqWq9dRfpbyLkeGRCwOeMDd7p1aH6eaIpbJ ytoIF6njfY/t9ju3kSgineXtxaJ0GoniyjbWzBPLiwPlx0gs7LGE0OgL5Hdem3uBeZwr 4i+VeWEmWcVvdn8/X3/NnD0/JhjFZuaZhRCq9yqv2IcQFt4B2MhDAgWCKpTaQ+zghH1p MA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2y8udd881t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 08:43:13 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 01K8bnNp079829; Thu, 20 Feb 2020 08:43:12 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3020.oracle.com with ESMTP id 2y8udbd8vm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 20 Feb 2020 08:43:12 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 01K8h8m4010277; Thu, 20 Feb 2020 08:43:08 GMT Received: from kadam (/129.205.23.165) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 20 Feb 2020 00:43:07 -0800 Date: Thu, 20 Feb 2020 11:42:55 +0300 From: Dan Carpenter To: Scott Branden Cc: Luis Chamberlain , Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross Subject: Re: [PATCH v2 3/7] test_firmware: add partial read support for request_firmware_into_buf Message-ID: <20200220084255.GW7838@kadam> References: <20200220004825.23372-1-scott.branden@broadcom.com> <20200220004825.23372-4-scott.branden@broadcom.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200220004825.23372-4-scott.branden@broadcom.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=999 phishscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200064 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9536 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 phishscore=0 impostorscore=0 mlxlogscore=999 malwarescore=0 mlxscore=0 suspectscore=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2001150001 definitions=main-2002200064 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 04:48:21PM -0800, Scott Branden wrote: > +static int test_dev_config_update_size_t(const char *buf, > + size_t size, > + size_t *cfg) > +{ > + int ret; > + long new; > + > + ret = kstrtol(buf, 10, &new); > + if (ret) > + return ret; > + > + if (new > SIZE_MAX) This "new" variable is long and SIZE_MAX is ULONG_MAX so the condition can't be true. > + return -EINVAL; > + > + mutex_lock(&test_fw_mutex); > + *(size_t *)cfg = new; > + mutex_unlock(&test_fw_mutex); > + > + /* Always return full write size even if we didn't consume all */ > + return size; > +} > + > +static ssize_t test_dev_config_show_size_t(char *buf, int cfg) > +{ > + size_t val; > + > + mutex_lock(&test_fw_mutex); > + val = cfg; > + mutex_unlock(&test_fw_mutex); Both val and cfg are stack variables so there is no need for locking. Probably you meant to pass a pointer to cfg? > + > + return snprintf(buf, PAGE_SIZE, "%zu\n", val); > +} > + > static ssize_t test_dev_config_show_int(char *buf, int cfg) > { > int val; regards, dan carpenter