All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ocfs2: Fix error path kobject memory leak
@ 2019-05-13  3:34 Tobin C. Harding
  2019-05-13  7:14   ` [Ocfs2-devel] " Greg Kroah-Hartman
  2019-05-13  7:28   ` [Ocfs2-devel] " Joseph Qi
  0 siblings, 2 replies; 5+ messages in thread
From: Tobin C. Harding @ 2019-05-13  3:34 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, Greg Kroah-Hartman, Rafael J. Wysocki,
	ocfs2-devel, linux-kernel
  Cc: Tobin C. Harding

If a call to kobject_init_and_add() fails we should call kobject_put()
otherwise we leak memory.

Add call to kobject_put() in the error path of call to
kobject_init_and_add().  Please note, this has the side effect that
the release method is called if kobject_init_and_add() fails.

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
---

Is it ok to send patches during the merge window?

Applies on top of Linus' mainline tag: v5.1

Happy to rebase if there are conflicts.

thanks,
Tobin.

 fs/ocfs2/filecheck.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
index f65f2b2f594d..1906cc962c4d 100644
--- a/fs/ocfs2/filecheck.c
+++ b/fs/ocfs2/filecheck.c
@@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)
 	ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck,
 					NULL, "filecheck");
 	if (ret) {
+		kobject_put(&entry->fs_kobj);
 		kfree(fcheck);
 		return ret;
 	}
-- 
2.21.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ocfs2: Fix error path kobject memory leak
  2019-05-13  3:34 [PATCH] ocfs2: Fix error path kobject memory leak Tobin C. Harding
@ 2019-05-13  7:14   ` Greg Kroah-Hartman
  2019-05-13  7:28   ` [Ocfs2-devel] " Joseph Qi
  1 sibling, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-05-13  7:14 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: Mark Fasheh, Joel Becker, Rafael J. Wysocki, ocfs2-devel, linux-kernel

On Mon, May 13, 2019 at 01:34:58PM +1000, Tobin C. Harding wrote:
> If a call to kobject_init_and_add() fails we should call kobject_put()
> otherwise we leak memory.
> 
> Add call to kobject_put() in the error path of call to
> kobject_init_and_add().  Please note, this has the side effect that
> the release method is called if kobject_init_and_add() fails.
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> ---

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Ocfs2-devel] [PATCH] ocfs2: Fix error path kobject memory leak
@ 2019-05-13  7:14   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2019-05-13  7:14 UTC (permalink / raw)
  To: Tobin C. Harding
  Cc: Mark Fasheh, Joel Becker, Rafael J. Wysocki, ocfs2-devel, linux-kernel

On Mon, May 13, 2019 at 01:34:58PM +1000, Tobin C. Harding wrote:
> If a call to kobject_init_and_add() fails we should call kobject_put()
> otherwise we leak memory.
> 
> Add call to kobject_put() in the error path of call to
> kobject_init_and_add().  Please note, this has the side effect that
> the release method is called if kobject_init_and_add() fails.
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>
> ---

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ocfs2: Fix error path kobject memory leak
  2019-05-13  3:34 [PATCH] ocfs2: Fix error path kobject memory leak Tobin C. Harding
@ 2019-05-13  7:28   ` Joseph Qi
  2019-05-13  7:28   ` [Ocfs2-devel] " Joseph Qi
  1 sibling, 0 replies; 5+ messages in thread
From: Joseph Qi @ 2019-05-13  7:28 UTC (permalink / raw)
  To: Tobin C. Harding, Mark Fasheh, Joel Becker, Greg Kroah-Hartman,
	Rafael J. Wysocki, ocfs2-devel, linux-kernel
  Cc: Andrew Morton



On 19/5/13 11:34, Tobin C. Harding wrote:
> If a call to kobject_init_and_add() fails we should call kobject_put()
> otherwise we leak memory.
> 
> Add call to kobject_put() in the error path of call to
> kobject_init_and_add().  Please note, this has the side effect that
> the release method is called if kobject_init_and_add() fails.
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>

Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> ---
> 
> Is it ok to send patches during the merge window?
> 
> Applies on top of Linus' mainline tag: v5.1
> 
> Happy to rebase if there are conflicts.
> 
> thanks,
> Tobin.
> 
>  fs/ocfs2/filecheck.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
> index f65f2b2f594d..1906cc962c4d 100644
> --- a/fs/ocfs2/filecheck.c
> +++ b/fs/ocfs2/filecheck.c
> @@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)
>  	ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck,
>  					NULL, "filecheck");
>  	if (ret) {
> +		kobject_put(&entry->fs_kobj);
>  		kfree(fcheck);
>  		return ret;
>  	}
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [Ocfs2-devel] [PATCH] ocfs2: Fix error path kobject memory leak
@ 2019-05-13  7:28   ` Joseph Qi
  0 siblings, 0 replies; 5+ messages in thread
From: Joseph Qi @ 2019-05-13  7:28 UTC (permalink / raw)
  To: Tobin C. Harding, Mark Fasheh, Joel Becker, Greg Kroah-Hartman,
	Rafael J. Wysocki, ocfs2-devel, linux-kernel
  Cc: Andrew Morton



On 19/5/13 11:34, Tobin C. Harding wrote:
> If a call to kobject_init_and_add() fails we should call kobject_put()
> otherwise we leak memory.
> 
> Add call to kobject_put() in the error path of call to
> kobject_init_and_add().  Please note, this has the side effect that
> the release method is called if kobject_init_and_add() fails.
> 
> Signed-off-by: Tobin C. Harding <tobin@kernel.org>

Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
> ---
> 
> Is it ok to send patches during the merge window?
> 
> Applies on top of Linus' mainline tag: v5.1
> 
> Happy to rebase if there are conflicts.
> 
> thanks,
> Tobin.
> 
>  fs/ocfs2/filecheck.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c
> index f65f2b2f594d..1906cc962c4d 100644
> --- a/fs/ocfs2/filecheck.c
> +++ b/fs/ocfs2/filecheck.c
> @@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb)
>  	ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck,
>  					NULL, "filecheck");
>  	if (ret) {
> +		kobject_put(&entry->fs_kobj);
>  		kfree(fcheck);
>  		return ret;
>  	}
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-13  7:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13  3:34 [PATCH] ocfs2: Fix error path kobject memory leak Tobin C. Harding
2019-05-13  7:14 ` Greg Kroah-Hartman
2019-05-13  7:14   ` [Ocfs2-devel] " Greg Kroah-Hartman
2019-05-13  7:28 ` Joseph Qi
2019-05-13  7:28   ` [Ocfs2-devel] " Joseph Qi

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.