drivers/base/cpu: remove redundant assignment of variable retval
authorColin Ian King <colin.king@canonical.com>
Thu, 18 Feb 2021 20:28:37 +0000 (20:28 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Mar 2021 13:56:50 +0000 (14:56 +0100)
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.

Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Link: https://lore.kernel.org/r/20210218202837.516231-1-colin.king@canonical.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/cpu.c

index 8f1d656..2b9e413 100644 (file)
@@ -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;