ocfs2: Fix error path kobject memory leak
PATCH 1/1 ocfs2: Fix error path kobject memory leak
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.
---
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(+)
fs/ocfs2/filecheck.c +1 -0
@@ -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; }
Signature · 1 line
2.21.0
Quoted 9 lines · Tobin C. Harding
If a call to
kobject_init_and_add()fails we should callkobject_put()otherwise we leak memory.Add call to
kobject_put()in the error path of call tokobject_init_and_add(). Please note, this has the side effect that the release method is called ifkobject_init_and_add()fails.Signed-off-by Tobin C. Harding <[email protected]>---
Quoted 8 lines · Tobin C. Harding
If a call to
kobject_init_and_add()fails we should callkobject_put()otherwise we leak memory.Add call to
kobject_put()in the error path of call tokobject_init_and_add(). Please note, this has the side effect that the release method is called ifkobject_init_and_add()fails.Signed-off-by Tobin C. Harding <[email protected]>
Quoted 27 lines
---
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(+)fs/ocfs2/filecheck.c +1
-0@@ -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; }