All of lore.kernel.org
 help / color / mirror / Atom feed
From: Borislav Petkov <bp@alien8.de>
To: Junjie Mao <junjie_mao@yeah.net>
Cc: Doug Thompson <dougthompson@xmission.com>,
	Mauro Carvalho Chehab <mchehab@osg.samsung.com>,
	linux-edac@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] edac: fix the leak of mci->bus->name when bus_register fails
Date: Wed, 28 Jan 2015 12:42:03 +0100	[thread overview]
Message-ID: <20150128114203.GA7569@pd.tnic> (raw)
In-Reply-To: <1422425736-15968-1-git-send-email-junjie_mao@yeah.net>

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@yeah.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.
--

           reply	other threads:[~2015-01-29  1:50 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <1422425736-15968-1-git-send-email-junjie_mao@yeah.net>]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150128114203.GA7569@pd.tnic \
    --to=bp@alien8.de \
    --cc=dougthompson@xmission.com \
    --cc=junjie_mao@yeah.net \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@osg.samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.