Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2504290ybv; Fri, 21 Feb 2020 17:14:36 -0800 (PST) X-Google-Smtp-Source: APXvYqwuq/21+zQCQDn7IVfJjQpWDXFKNM3EEiXNmKgL1ZgYOkSIHofnKsjwPckTIfpV8bfBh4Y4 X-Received: by 2002:a05:6808:902:: with SMTP id w2mr4433587oih.170.1582334076268; Fri, 21 Feb 2020 17:14:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582334076; cv=none; d=google.com; s=arc-20160816; b=nGcg32QmkrnYBO5PId9KXDNTrPe7ZYGCn4UZcTrXRVM7IODS5aHT99WSFDAtjQHO3+ pt21yJqPRo8ftNZEPaFlYNklpRjrt3zNva/m3b4cul5Ql8hbda3tAJFS/KtYtEf581bS UG+85NyQUjb5tV7g9I9HMf4FMMxw4kcq9cNu9d3I2h1hZ+06kFZZlO3GNVJufH8ZjIxu Gz8a2thS1q6dgf2AhMyg8JTVCcqLtXvhK669RFLbLbtsEJfgytM6R+YpYQ70fIe7oiBW JJ/8tlYbdrFB3NwC/jZbFRfntuxdtVWK0q5H8q8Q31ZKy8Qe9utZ7vXWPBTUcnQz6Uc/ xIUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:from:subject:dkim-signature; bh=3OKaYIHAkscSICnojjLFVcfWriWY1zhvs1Wig+8n2u0=; b=kmMsU39F4f3bvuhvpscOwrnWmA3o6alZ07ReY+WaXfvDACScoRlnhXfgl9NpCqONXv B2DiCYGU1cr8npEEE7bPxcmtBrCkD+ApwhV4IAEK9r4yKXYfOv2w1meikF4oaATi4qom 7+zX2YvnLkm6WqOK8GP+eNvSNYjYFiX55z54qlo/lo9yiCgnn7Dx4z3gewLC5LCgUSro e009j9j0JOv1IzDsk5xQ71nYFTBNb8BCCWYVOssIkmMg42Xz/UOcXYsFQvifAFCPifO9 oWLzDxxxavAv2s2q6m50aTfP34bOl47tjDXoH/Zhm6XDkenv2LEGKuL0CMr2CYwcLilX b84w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=YuZBob4g; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f23si2203875oti.283.2020.02.21.17.14.23; Fri, 21 Feb 2020 17:14:36 -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=@broadcom.com header.s=google header.b=YuZBob4g; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727823AbgBVBNT (ORCPT + 99 others); Fri, 21 Feb 2020 20:13:19 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:38540 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbgBVBNR (ORCPT ); Fri, 21 Feb 2020 20:13:17 -0500 Received: by mail-wr1-f67.google.com with SMTP id e8so3989772wrm.5 for ; Fri, 21 Feb 2020 17:13:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=3OKaYIHAkscSICnojjLFVcfWriWY1zhvs1Wig+8n2u0=; b=YuZBob4gmx9BoVF20MxUMC4n/O2CRqr7f4PfEbgIjSUOmHRoUON6ioN3lQAp+XaXsc YnYlGLs9XUL5tqmnh9TRTJpQR9PkRpU7GY0fmQqqqDpcTwhwfmm1AeAHh63DYxj94wDt /6xbAUPlaRkR7P/ddUn1r3McPYwTMEWRdXBmk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=3OKaYIHAkscSICnojjLFVcfWriWY1zhvs1Wig+8n2u0=; b=NO6+IUrHoDFI5d1hclGksDNYI6CC7tZXeiIIlnEVYBljgAEbtUTYwy1zZsmZhS+EyN cK11ifI6X0hZNBCUCItcbuJuTRltuJNTgwUw/NI9gTVwcCOh8bqAG9rUb63sQYhKnq9j Oqez+edyJvwNT/Q1zsAeGoPuxI/XaIJA0gSczY7lOkAOvOcL82jVVbx35+quxU8nGoK4 o9inxVu2unKSXLNbLmkkfBHcO7gMFs1gqRNPx62hvbE1s+viwtEfGBwFBrCm+Skxro3U WT1MvtIUNi2qxH7Ta81hKgmHIvNiq49uTBsgAhsEWCvHCKQr3nllvxtSNMs811dnVbEK 3O1g== X-Gm-Message-State: APjAAAWHaaZg7TIkxHQsJbINn+Cw1qV51OM5pJbgHlpRDNvvJ4Roe8jK wc1r5uaaANneOZoG5hvxPe/ZnA== X-Received: by 2002:adf:e683:: with SMTP id r3mr54339138wrm.38.1582333995403; Fri, 21 Feb 2020 17:13:15 -0800 (PST) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id d4sm6275870wra.14.2020.02.21.17.13.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 21 Feb 2020 17:13:14 -0800 (PST) Subject: Re: [PATCH v2 3/7] test_firmware: add partial read support for request_firmware_into_buf From: Scott Branden To: Dan Carpenter 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 References: <20200220004825.23372-1-scott.branden@broadcom.com> <20200220004825.23372-4-scott.branden@broadcom.com> <20200220084255.GW7838@kadam> <9afab7f8-1b5f-a7bb-6b76-f7b19efb2979@broadcom.com> Message-ID: <4a666590-461d-17f9-5580-31a41869383f@broadcom.com> Date: Fri, 21 Feb 2020 17:13:08 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <9afab7f8-1b5f-a7bb-6b76-f7b19efb2979@broadcom.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Reponses inline. Luis - please have a look as well. On 2020-02-21 10:30 a.m., Scott Branden wrote: > Hi Dan, > > Thanks for your review and valuable comments. > Will have to investigate fully and correct anything wrong. > > On 2020-02-20 12:42 a.m., Dan Carpenter wrote: >> 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. Removed the check. >> >>> +        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? I am following the existing code as was done for test_dev_config_show_bool(), test_dev_config_show_int(), test_dev_config_show_u8() Mutex probably not needed but I don't think I need to deviate from the rest of the test code. Luis, could you please explain what the rest of your code is doing? >> >>> + >>> +    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 >> >> >