mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Chen Lin Z <lin.z.chen@intel.com>
Cc: linux-kernel@vger.kernel.org, bo.he@intel.com,
	yanmin_zhang@linux.intel.com
Subject: Re: [PATCH] driver core: bus: Free the kobject.name if kset_register fails
Date: Wed, 5 Aug 2015 17:01:20 -0700	[thread overview]
Message-ID: <20150806000120.GA25419@kroah.com> (raw)
In-Reply-To: <1433840721-15918-1-git-send-email-lin.z.chen@intel.com>

On Tue, Jun 09, 2015 at 05:05:21PM +0800, Chen Lin Z wrote:
> if register two bus with the same name, kset_register will fail.
> it need free kobject.name, otherwise there is a memory leak.
> 
> Signed-off-by: Chen Lin Z <lin.z.chen@intel.com>
> ---
>  drivers/base/bus.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/base/bus.c b/drivers/base/bus.c
> index 79bc203..9375048 100644
> --- a/drivers/base/bus.c
> +++ b/drivers/base/bus.c
> @@ -894,8 +894,10 @@ int bus_register(struct bus_type *bus)
>  	priv->drivers_autoprobe = 1;
>  
>  	retval = kset_register(&priv->subsys);
> -	if (retval)
> +	if (retval) {
> +		kfree(priv->subsys.kobj.name);

This doesn't solve the problem properly, as all of the other error paths
also need to free this memory.

And I really hate to poke around this "deep" into the kobject core, but
I understand it's needed here :(

thanks,

greg k-h

      reply	other threads:[~2015-08-06  0:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-09  9:05 Chen Lin Z
2015-08-06  0:01 ` Greg KH [this message]

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=20150806000120.GA25419@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=bo.he@intel.com \
    --cc=lin.z.chen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yanmin_zhang@linux.intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®