]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
driver core: cpu: use put_device() if device_register fail
authorArvind Yadav <arvind.yadav.cs@gmail.com>
Sun, 11 Mar 2018 05:55:51 +0000 (11:25 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 Mar 2018 13:37:04 +0000 (14:37 +0100)
if device_register() returned an error! Always use put_device()
to give up the reference initialized.

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/cpu.c

index d21a2d913107087a349ecaa7d62160615a255820..2da998baa75cb26714783bcce909332f8ae8e75e 100644 (file)
@@ -382,8 +382,10 @@ int register_cpu(struct cpu *cpu, int num)
        if (cpu->hotpluggable)
                cpu->dev.groups = hotplugable_cpu_attr_groups;
        error = device_register(&cpu->dev);
-       if (error)
+       if (error) {
+               put_device(&cpu->dev);
                return error;
+       }
 
        per_cpu(cpu_sys_devices, num) = &cpu->dev;
        register_cpu_under_node(num, cpu_to_node(num));