lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20150128114203.GA7569@pd.tnic>
Date:	Wed, 28 Jan 2015 12:42:03 +0100
From:	Borislav Petkov <bp@...en8.de>
To:	Junjie Mao <junjie_mao@...h.net>
Cc:	Doug Thompson <dougthompson@...ssion.com>,
	Mauro Carvalho Chehab <mchehab@....samsung.com>,
	linux-edac@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] edac: fix the leak of mci->bus->name when bus_register
 fails

On Wed, Jan 28, 2015 at 02:15:36PM +0800, Junjie Mao wrote:
> Use goto labels for all failure paths in edac_create_sysfs_mci_device.
> 
> Signed-off-by: Junjie Mao <junjie_mao@...h.net>
> ---
>  drivers/edac/edac_mc_sysfs.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
> index 670d2829c547..16f3720f9b73 100644
> --- a/drivers/edac/edac_mc_sysfs.c
> +++ b/drivers/edac/edac_mc_sysfs.c
> @@ -989,7 +989,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
>  
>  	err = bus_register(mci->bus);
>  	if (err < 0)
> -		return err;
> +		goto fail_free_name;
>  
>  	/* get the /sys/devices/system/edac subsys reference */
>  	mci->dev.type = &mci_attr_type;
> @@ -1005,9 +1005,7 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
>  	err = device_add(&mci->dev);
>  	if (err < 0) {
>  		edac_dbg(1, "failure: create device %s\n", dev_name(&mci->dev));
> -		bus_unregister(mci->bus);
> -		kfree(mci->bus->name);
> -		return err;
> +		goto fail_unregister_bus;
>  	}
>  
>  	if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
> @@ -1072,7 +1070,9 @@ fail:
>  	}
>  fail2:

Looks ok.

Can you please change those nothing-telling label names "fail" and
"fail2" into something more descriptive, while you're at it?

>  	device_unregister(&mci->dev);
> +fail_unregister_bus:
>  	bus_unregister(mci->bus);
> +fail_free_name:
>  	kfree(mci->bus->name);
>  	return err;

Thanks.

-- 
Regards/Gruss,
    Boris.

ECO tip #101: Trim your mails when you reply.
--
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ