]> git.baikalelectronics.ru Git - kernel.git/commit
gfs2: Fix error path kobject memory leak
authorTobin C. Harding <tobin@kernel.org>
Mon, 13 May 2019 19:59:04 +0000 (21:59 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 13 May 2019 22:43:01 +0000 (15:43 -0700)
commit6adc9283ed5337f36827e471eb9c42830d23840a
treef779a08cbad359a2b34b67327c66e9aedf32a584
parent0f9f60491031fe484a92a6aef6780455f4111183
gfs2: Fix error path kobject memory leak

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

Function gfs2_sys_fs_add always calls kobject_init_and_add() which
always calls kobject_init().

It is safe to leave object destruction up to the kobject release
function and never free it manually.

Remove call to kfree() and always call kobject_put() in the error path.

Signed-off-by: Tobin C. Harding <tobin@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/gfs2/sys.c