Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201354 > unrolled thread

Re: [PATCH] driver core: bus: Free the kobject.name if kset_register fails

Started byGreg KH <gregkh@linuxfoundation.org>
First post2015-08-06 02:10 +0200
Last post2015-08-06 02:10 +0200
Articles 1 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH] driver core: bus: Free the kobject.name if kset_register  fails Greg KH <gregkh@linuxfoundation.org> - 2015-08-06 02:10 +0200

#1201354 — Re: [PATCH] driver core: bus: Free the kobject.name if kset_register fails

FromGreg KH <gregkh@linuxfoundation.org>
Date2015-08-06 02:10 +0200
SubjectRe: [PATCH] driver core: bus: Free the kobject.name if kset_register fails
Message-ID<pUgUY-eG-43@gated-at.bofh.it>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [standalone]


Back to top | Article view | linux.kernel


csiph-web