summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2016-04-03 15:22:08 +0300
committerMichael S. Tsirkin <mst@redhat.com>2016-04-07 15:16:39 +0300
commite8aabc64d7f5c8702e420c6fa478368f60718ae4 (patch)
treeeae09e5ae7f60e8e2e375b6792639da64f71720f /drivers
parent9735a22799b9214d17d3c231fe377fc852f042e9 (diff)
downloadlinux-e8aabc64d7f5c8702e420c6fa478368f60718ae4.tar.gz
linux-e8aabc64d7f5c8702e420c6fa478368f60718ae4.tar.bz2
linux-e8aabc64d7f5c8702e420c6fa478368f60718ae4.zip
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: Michael S. Tsirkin <mst@redhat.com> Acked-by: Gabriel Somlo <somlo@cmu.edu>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/firmware/qemu_fw_cfg.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
index fedbff55a7f3..e4c471413d46 100644
--- a/drivers/firmware/qemu_fw_cfg.c
+++ b/drivers/firmware/qemu_fw_cfg.c
@@ -727,12 +727,18 @@ device_param_cb(mmio, &fw_cfg_cmdline_param_ops, NULL, S_IRUSR);
static int __init fw_cfg_sysfs_init(void)
{
+ int ret;
+
/* create /sys/firmware/qemu_fw_cfg/ top level directory */
fw_cfg_top_ko = kobject_create_and_add("qemu_fw_cfg", firmware_kobj);
if (!fw_cfg_top_ko)
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)