]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/pseries/vas: Call misc_deregister if sysfs init fails
authorZheng Bin <zhengbin13@huawei.com>
Wed, 11 May 2022 03:35:07 +0000 (11:35 +0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sun, 22 May 2022 05:58:31 +0000 (15:58 +1000)
Undo effects of misc_register if sysfs init fails after
misc_register.

Signed-off-by: Zheng Bin <zhengbin13@huawei.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220511033507.2745992-1-zhengbin13@huawei.com
arch/powerpc/platforms/pseries/vas-sysfs.c

index d06c0a06de8bc64fe47f5b93b71df371f9b7987e..f9f682724e776356fee595da562c1dfac75fa847 100644 (file)
@@ -248,6 +248,7 @@ int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps)
        pseries_vas_kobj = kobject_create_and_add("vas0",
                                        &vas_miscdev.this_device->kobj);
        if (!pseries_vas_kobj) {
+               misc_deregister(&vas_miscdev);
                pr_err("Failed to create VAS sysfs entry\n");
                return -ENOMEM;
        }
@@ -259,6 +260,7 @@ int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps)
                if (!gzip_caps_kobj) {
                        pr_err("Failed to create VAS GZIP capability entry\n");
                        kobject_put(pseries_vas_kobj);
+                       misc_deregister(&vas_miscdev);
                        return -ENOMEM;
                }
        }