Prev: Driver core: Fix potential memory leak
Next: Driver core: Fix memory leak on class_register error path
From: Greg KH on 22 Jul 2010 19:50 On Thu, Jul 22, 2010 at 03:09:06PM -0700, Patrick Pannuto wrote: > This leak is the same as the bus path; kset->kobj.name is > set, but kset_register fails, thus nothing will ever call > kset_unregister and name will be leaked > > Signed-off-by: Patrick Pannuto <ppannuto(a)codeaurora.org> > --- > lib/kobject.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/lib/kobject.c b/lib/kobject.c > index f07c572..713b235 100644 > --- a/lib/kobject.c > +++ b/lib/kobject.c > @@ -843,6 +843,7 @@ struct kset *kset_create_and_add(const char *name, > return NULL; > error = kset_register(kset); > if (error) { > + kfree(kset->kobj.name); Again, we should be able to clean this up automatically better than forcing this code to "know" that it has to handle this. Any other ideas? And are these error paths something that you have seen in a working system? thanks, greg k-h -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |