[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20160406171646.GP2060@HEDWIG.INI.CMU.EDU>
Date: Wed, 6 Apr 2016 13:16:46 -0400
From: "Gabriel L. Somlo" <somlo@....edu>
To: "Michael S. Tsirkin" <mst@...hat.com>
Cc: linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Andreas Ziegler <andreas.ziegler@....de>,
Valentin Rothberg <valentin.rothberg@...teo.net>
Subject: Re: [PATCH] qemu_fw_cfg: don't leak kobj on init error
On Sun, Apr 03, 2016 at 03:23:19PM +0300, Michael S. Tsirkin wrote:
> If platform_driver_register fails, we should
> cleanup fw_cfg_top_ko before exiting.
>
> Signed-off-by: Michael S. Tsirkin <mst@...hat.com>
Acked-by: Gabriel Somlo <somlo@....edu>
Thanks,
--Gabriel
> ---
> drivers/firmware/qemu_fw_cfg.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/firmware/qemu_fw_cfg.c b/drivers/firmware/qemu_fw_cfg.c
> index fedbff5..e4c4714 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)
> --
> MST
Powered by blists - more mailing lists