* [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
@ 2020-04-15 0:25 Scott Branden
2020-04-15 3:10 ` Kees Cook
0 siblings, 1 reply; 5+ messages in thread
From: Scott Branden @ 2020-04-15 0:25 UTC (permalink / raw)
To: Luis Chamberlain, Greg Kroah-Hartman, David Brown,
Alexander Viro, Shuah Khan, bjorn.andersson, Shuah Khan,
Arnd Bergmann
Cc: Rafael J . Wysocki, linux-kernel, linux-arm-msm, linux-fsdevel,
BCM Kernel Feedback, Olof Johansson, Andrew Morton,
Dan Carpenter, Colin Ian King, Kees Cook, Takashi Iwai,
linux-kselftest, Andy Gross, Scott Branden
Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
functions that show simple bool, int, and u8.
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
---
lib/test_firmware.c | 26 +++-----------------------
1 file changed, 3 insertions(+), 23 deletions(-)
diff --git a/lib/test_firmware.c b/lib/test_firmware.c
index 0c7fbcf07ac5..9fee2b93a8d1 100644
--- a/lib/test_firmware.c
+++ b/lib/test_firmware.c
@@ -310,27 +310,13 @@ static int test_dev_config_update_bool(const char *buf, size_t size,
return ret;
}
-static ssize_t
-test_dev_config_show_bool(char *buf,
- bool config)
+static ssize_t test_dev_config_show_bool(char *buf, bool val)
{
- bool val;
-
- mutex_lock(&test_fw_mutex);
- val = config;
- mutex_unlock(&test_fw_mutex);
-
return snprintf(buf, PAGE_SIZE, "%d\n", val);
}
-static ssize_t test_dev_config_show_int(char *buf, int cfg)
+static ssize_t test_dev_config_show_int(char *buf, int val)
{
- int val;
-
- mutex_lock(&test_fw_mutex);
- val = cfg;
- mutex_unlock(&test_fw_mutex);
-
return snprintf(buf, PAGE_SIZE, "%d\n", val);
}
@@ -354,14 +340,8 @@ static int test_dev_config_update_u8(const char *buf, size_t size, u8 *cfg)
return size;
}
-static ssize_t test_dev_config_show_u8(char *buf, u8 cfg)
+static ssize_t test_dev_config_show_u8(char *buf, u8 val)
{
- u8 val;
-
- mutex_lock(&test_fw_mutex);
- val = cfg;
- mutex_unlock(&test_fw_mutex);
-
return snprintf(buf, PAGE_SIZE, "%u\n", val);
}
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
2020-04-15 0:25 [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx Scott Branden
@ 2020-04-15 3:10 ` Kees Cook
2020-04-15 16:28 ` Scott Branden
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2020-04-15 3:10 UTC (permalink / raw)
To: Scott Branden
Cc: Luis Chamberlain, Greg Kroah-Hartman, David Brown,
Alexander Viro, Shuah Khan, bjorn.andersson, Shuah Khan,
Arnd Bergmann, Rafael J . Wysocki, linux-kernel, linux-arm-msm,
linux-fsdevel, BCM Kernel Feedback, Olof Johansson,
Andrew Morton, Dan Carpenter, Colin Ian King, Takashi Iwai,
linux-kselftest, Andy Gross
On Tue, Apr 14, 2020 at 05:25:17PM -0700, Scott Branden wrote:
> Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
> functions that show simple bool, int, and u8.
I would expect at least a READ_ONCE(), yes?
>
> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> ---
> lib/test_firmware.c | 26 +++-----------------------
> 1 file changed, 3 insertions(+), 23 deletions(-)
>
> diff --git a/lib/test_firmware.c b/lib/test_firmware.c
> index 0c7fbcf07ac5..9fee2b93a8d1 100644
> --- a/lib/test_firmware.c
> +++ b/lib/test_firmware.c
> @@ -310,27 +310,13 @@ static int test_dev_config_update_bool(const char *buf, size_t size,
> return ret;
> }
>
> -static ssize_t
> -test_dev_config_show_bool(char *buf,
> - bool config)
> +static ssize_t test_dev_config_show_bool(char *buf, bool val)
> {
> - bool val;
> -
> - mutex_lock(&test_fw_mutex);
> - val = config;
> - mutex_unlock(&test_fw_mutex);
> -
> return snprintf(buf, PAGE_SIZE, "%d\n", val);
> }
>
> -static ssize_t test_dev_config_show_int(char *buf, int cfg)
> +static ssize_t test_dev_config_show_int(char *buf, int val)
> {
> - int val;
> -
> - mutex_lock(&test_fw_mutex);
> - val = cfg;
> - mutex_unlock(&test_fw_mutex);
> -
> return snprintf(buf, PAGE_SIZE, "%d\n", val);
> }
>
> @@ -354,14 +340,8 @@ static int test_dev_config_update_u8(const char *buf, size_t size, u8 *cfg)
> return size;
> }
>
> -static ssize_t test_dev_config_show_u8(char *buf, u8 cfg)
> +static ssize_t test_dev_config_show_u8(char *buf, u8 val)
> {
> - u8 val;
> -
> - mutex_lock(&test_fw_mutex);
> - val = cfg;
> - mutex_unlock(&test_fw_mutex);
> -
> return snprintf(buf, PAGE_SIZE, "%u\n", val);
> }
>
> --
> 2.17.1
>
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
2020-04-15 3:10 ` Kees Cook
@ 2020-04-15 16:28 ` Scott Branden
2020-04-15 16:44 ` Kees Cook
0 siblings, 1 reply; 5+ messages in thread
From: Scott Branden @ 2020-04-15 16:28 UTC (permalink / raw)
To: Kees Cook
Cc: Luis Chamberlain, Greg Kroah-Hartman, David Brown,
Alexander Viro, Shuah Khan, bjorn.andersson, Shuah Khan,
Arnd Bergmann, Rafael J . Wysocki, linux-kernel, linux-arm-msm,
linux-fsdevel, BCM Kernel Feedback, Olof Johansson,
Andrew Morton, Dan Carpenter, Colin Ian King, Takashi Iwai,
linux-kselftest, Andy Gross
Hi Kees,
On 2020-04-14 8:10 p.m., Kees Cook wrote:
> On Tue, Apr 14, 2020 at 05:25:17PM -0700, Scott Branden wrote:
>> Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
>> functions that show simple bool, int, and u8.
> I would expect at least a READ_ONCE(), yes?
I don't understand why you need a READ_ONCE when removing a mutex around
an assignment
of a parameter passed into a function being assigned to a local variable.
Could you please explain your expectations.
>
>> Signed-off-by: Scott Branden <scott.branden@broadcom.com>
>> ---
>> lib/test_firmware.c | 26 +++-----------------------
>> 1 file changed, 3 insertions(+), 23 deletions(-)
>>
>> diff --git a/lib/test_firmware.c b/lib/test_firmware.c
>> index 0c7fbcf07ac5..9fee2b93a8d1 100644
>> --- a/lib/test_firmware.c
>> +++ b/lib/test_firmware.c
>> @@ -310,27 +310,13 @@ static int test_dev_config_update_bool(const char *buf, size_t size,
>> return ret;
>> }
>>
>> -static ssize_t
>> -test_dev_config_show_bool(char *buf,
>> - bool config)
>> +static ssize_t test_dev_config_show_bool(char *buf, bool val)
>> {
>> - bool val;
>> -
>> - mutex_lock(&test_fw_mutex);
>> - val = config;
>> - mutex_unlock(&test_fw_mutex);
>> -
>> return snprintf(buf, PAGE_SIZE, "%d\n", val);
>> }
>>
>> -static ssize_t test_dev_config_show_int(char *buf, int cfg)
>> +static ssize_t test_dev_config_show_int(char *buf, int val)
>> {
>> - int val;
>> -
>> - mutex_lock(&test_fw_mutex);
>> - val = cfg;
>> - mutex_unlock(&test_fw_mutex);
>> -
>> return snprintf(buf, PAGE_SIZE, "%d\n", val);
>> }
>>
>> @@ -354,14 +340,8 @@ static int test_dev_config_update_u8(const char *buf, size_t size, u8 *cfg)
>> return size;
>> }
>>
>> -static ssize_t test_dev_config_show_u8(char *buf, u8 cfg)
>> +static ssize_t test_dev_config_show_u8(char *buf, u8 val)
>> {
>> - u8 val;
>> -
>> - mutex_lock(&test_fw_mutex);
>> - val = cfg;
>> - mutex_unlock(&test_fw_mutex);
>> -
>> return snprintf(buf, PAGE_SIZE, "%u\n", val);
>> }
>>
>> --
>> 2.17.1
>>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
2020-04-15 16:28 ` Scott Branden
@ 2020-04-15 16:44 ` Kees Cook
2020-04-16 6:00 ` Luis Chamberlain
0 siblings, 1 reply; 5+ messages in thread
From: Kees Cook @ 2020-04-15 16:44 UTC (permalink / raw)
To: Scott Branden
Cc: Luis Chamberlain, Greg Kroah-Hartman, David Brown,
Alexander Viro, Shuah Khan, bjorn.andersson, Shuah Khan,
Arnd Bergmann, Rafael J . Wysocki, linux-kernel, linux-arm-msm,
linux-fsdevel, BCM Kernel Feedback, Olof Johansson,
Andrew Morton, Dan Carpenter, Colin Ian King, Takashi Iwai,
linux-kselftest, Andy Gross
On Wed, Apr 15, 2020 at 09:28:18AM -0700, Scott Branden wrote:
> Hi Kees,
>
> On 2020-04-14 8:10 p.m., Kees Cook wrote:
> > On Tue, Apr 14, 2020 at 05:25:17PM -0700, Scott Branden wrote:
> > > Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
> > > functions that show simple bool, int, and u8.
> > I would expect at least a READ_ONCE(), yes?
> I don't understand why you need a READ_ONCE when removing a mutex around an
> assignment
> of a parameter passed into a function being assigned to a local variable.
>
> Could you please explain your expectations.
Oops, yes, you're right. I misread and was thinking this was reading
from a global. This looks fine.
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> >
> > > Signed-off-by: Scott Branden <scott.branden@broadcom.com>
> > > ---
> > > lib/test_firmware.c | 26 +++-----------------------
> > > 1 file changed, 3 insertions(+), 23 deletions(-)
> > >
> > > diff --git a/lib/test_firmware.c b/lib/test_firmware.c
> > > index 0c7fbcf07ac5..9fee2b93a8d1 100644
> > > --- a/lib/test_firmware.c
> > > +++ b/lib/test_firmware.c
> > > @@ -310,27 +310,13 @@ static int test_dev_config_update_bool(const char *buf, size_t size,
> > > return ret;
> > > }
> > > -static ssize_t
> > > -test_dev_config_show_bool(char *buf,
> > > - bool config)
> > > +static ssize_t test_dev_config_show_bool(char *buf, bool val)
> > > {
> > > - bool val;
> > > -
> > > - mutex_lock(&test_fw_mutex);
> > > - val = config;
> > > - mutex_unlock(&test_fw_mutex);
> > > -
> > > return snprintf(buf, PAGE_SIZE, "%d\n", val);
> > > }
> > > -static ssize_t test_dev_config_show_int(char *buf, int cfg)
> > > +static ssize_t test_dev_config_show_int(char *buf, int val)
> > > {
> > > - int val;
> > > -
> > > - mutex_lock(&test_fw_mutex);
> > > - val = cfg;
> > > - mutex_unlock(&test_fw_mutex);
> > > -
> > > return snprintf(buf, PAGE_SIZE, "%d\n", val);
> > > }
> > > @@ -354,14 +340,8 @@ static int test_dev_config_update_u8(const char *buf, size_t size, u8 *cfg)
> > > return size;
> > > }
> > > -static ssize_t test_dev_config_show_u8(char *buf, u8 cfg)
> > > +static ssize_t test_dev_config_show_u8(char *buf, u8 val)
> > > {
> > > - u8 val;
> > > -
> > > - mutex_lock(&test_fw_mutex);
> > > - val = cfg;
> > > - mutex_unlock(&test_fw_mutex);
> > > -
> > > return snprintf(buf, PAGE_SIZE, "%u\n", val);
> > > }
> > > --
> > > 2.17.1
> > >
>
--
Kees Cook
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx
2020-04-15 16:44 ` Kees Cook
@ 2020-04-16 6:00 ` Luis Chamberlain
0 siblings, 0 replies; 5+ messages in thread
From: Luis Chamberlain @ 2020-04-16 6:00 UTC (permalink / raw)
To: Kees Cook
Cc: Scott Branden, Greg Kroah-Hartman, David Brown, Alexander Viro,
Shuah Khan, bjorn.andersson, Shuah Khan, Arnd Bergmann,
Rafael J . Wysocki, linux-kernel, linux-arm-msm, linux-fsdevel,
BCM Kernel Feedback, Olof Johansson, Andrew Morton,
Dan Carpenter, Colin Ian King, Takashi Iwai, linux-kselftest,
Andy Gross
On Wed, Apr 15, 2020 at 09:44:31AM -0700, Kees Cook wrote:
> On Wed, Apr 15, 2020 at 09:28:18AM -0700, Scott Branden wrote:
> > Hi Kees,
> >
> > On 2020-04-14 8:10 p.m., Kees Cook wrote:
> > > On Tue, Apr 14, 2020 at 05:25:17PM -0700, Scott Branden wrote:
> > > > Remove unnecessary use of test_fw_mutex in test_dev_config_show_xxx
> > > > functions that show simple bool, int, and u8.
> > > I would expect at least a READ_ONCE(), yes?
> > I don't understand why you need a READ_ONCE when removing a mutex around an
> > assignment
> > of a parameter passed into a function being assigned to a local variable.
> >
> > Could you please explain your expectations.
>
> Oops, yes, you're right. I misread and was thinking this was reading
> from a global. This looks fine.
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Luis
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-16 6:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-15 0:25 [PATCH] test_firmware: remove unnecessary test_fw_mutex in test_dev_config_show_xxx Scott Branden
2020-04-15 3:10 ` Kees Cook
2020-04-15 16:28 ` Scott Branden
2020-04-15 16:44 ` Kees Cook
2020-04-16 6:00 ` Luis Chamberlain
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).