From: Michael S. Tsirkin Date: Sun, 3 Apr 2016 12:22:08 +0000 (+0300) Subject: qemu_fw_cfg: don't leak kobj on init error X-Git-Tag: MMI-PSA29.97-13-9~8161^2~4 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e8aabc64d7f5c8702e420c6fa478368f60718ae4;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git 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 Acked-by: Gabriel Somlo --- 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)