* [PATCH][V2] drivers/base/cpu: remove redundant assignment of variable retval
@ 2021-02-18 20:28 Colin King
2021-02-19 13:46 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-02-18 20:28 UTC (permalink / raw)
To: Greg Kroah-Hartman, Rafael J . Wysocki; +Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The variable retval is being initialized with a value that is never read
and it is being updated later with a new value. Clean this up by
initializing retval to -ENOMEM and remove the assignment to retval
on the !dev failure path.
Kudos to Rafael for the improved fix suggestion.
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V1: Remove initialization of retval
V2: Initialiation of retval with -ENOMEM and remove assignment in
!dev failure path.
---
drivers/base/cpu.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 8f1d6569564c..2b9e41377a07 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -409,13 +409,11 @@ __cpu_device_create(struct device *parent, void *drvdata,
const char *fmt, va_list args)
{
struct device *dev = NULL;
- int retval = -ENODEV;
+ int retval = -ENOMEM;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev) {
- retval = -ENOMEM;
+ if (!dev)
goto error;
- }
device_initialize(dev);
dev->parent = parent;
--
2.30.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][V2] drivers/base/cpu: remove redundant assignment of variable retval
2021-02-18 20:28 [PATCH][V2] drivers/base/cpu: remove redundant assignment of variable retval Colin King
@ 2021-02-19 13:46 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-02-19 13:46 UTC (permalink / raw)
To: Colin King
Cc: Greg Kroah-Hartman, Rafael J . Wysocki, kernel-janitors,
Linux Kernel Mailing List
On Thu, Feb 18, 2021 at 9:28 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> The variable retval is being initialized with a value that is never read
> and it is being updated later with a new value. Clean this up by
> initializing retval to -ENOMEM and remove the assignment to retval
> on the !dev failure path.
>
> Kudos to Rafael for the improved fix suggestion.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> ---
> V1: Remove initialization of retval
> V2: Initialiation of retval with -ENOMEM and remove assignment in
> !dev failure path.
> ---
> drivers/base/cpu.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 8f1d6569564c..2b9e41377a07 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -409,13 +409,11 @@ __cpu_device_create(struct device *parent, void *drvdata,
> const char *fmt, va_list args)
> {
> struct device *dev = NULL;
> - int retval = -ENODEV;
> + int retval = -ENOMEM;
>
> dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> - if (!dev) {
> - retval = -ENOMEM;
> + if (!dev)
> goto error;
> - }
>
> device_initialize(dev);
> dev->parent = parent;
> --
> 2.30.0
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-02-19 13:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-18 20:28 [PATCH][V2] drivers/base/cpu: remove redundant assignment of variable retval Colin King
2021-02-19 13:46 ` Rafael J. Wysocki
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).