Commit e8aabc64 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

qemu_fw_cfg: don't leak kobj on init error

If platform_driver_register fails, we should
cleanup fw_cfg_top_ko before exiting.
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
Acked-by: default avatarGabriel Somlo <somlo@cmu.edu>
parent 9735a227
...@@ -727,12 +727,18 @@ device_param_cb(mmio, &fw_cfg_cmdline_param_ops, NULL, S_IRUSR); ...@@ -727,12 +727,18 @@ device_param_cb(mmio, &fw_cfg_cmdline_param_ops, NULL, S_IRUSR);
static int __init fw_cfg_sysfs_init(void) static int __init fw_cfg_sysfs_init(void)
{ {
int ret;
/* create /sys/firmware/qemu_fw_cfg/ top level directory */ /* create /sys/firmware/qemu_fw_cfg/ top level directory */
fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj); fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj);
if (!fw_cfg_top_ko) if (!fw_cfg_top_ko)
return -ENOMEM; return -ENOMEM;
return platform_driver_register(&fw_cfg_sysfs_driver); ret = platform_driver_register(&fw_cfg_sysfs_driver);
if (ret)
fw_cfg_kobj_cleanup(fw_cfg_top_ko);
return ret;
} }
static void __exit fw_cfg_sysfs_exit(void) static void __exit fw_cfg_sysfs_exit(void)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment