linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix kobject error path memleaks
@ 2019-05-13  3:39 Tobin C. Harding
  2019-05-13  3:39 ` [PATCH 1/2] fs: btrfs: Fix error path kobject memory leak Tobin C. Harding
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Tobin C. Harding @ 2019-05-13  3:39 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: Tobin C. Harding, Greg Kroah-Hartman, Rafael J. Wysocki,
	linux-btrfs, linux-kernel

Hi,

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.

While auditing kobject_init_and_add() calls throughout the kernel it was
found that btrfs potentially has a couple of memleaks in the error path
code for kobject_init_and_add().

Failing calls to kobject_init_and_add() should be followed by a call to
kobject_put() since kobject_init_and_add() always calls kobject_init().

Of note, adding kobject_put() causes the release method to be called if
kobject_init_and_add() fails.  For patch #1 this means we don't have to
manually free the space_info or call percpu_counter_destroy() since
these are both done by the release method.  In the second patch, I
believe the added call to kobject_put() fits in with the fs_devices
lifecycle assumptions of open_ctree() but please could you review since
I am new to this code.

CC'ing the kobject maintainers/reviewers also.

Thanks,
Tobin.


Tobin C. Harding (2):
  fs: btrfs: Fix error path kobject memory leak
  fs: btrfs: Don't leak memory when failing add fsid

 fs/btrfs/extent-tree.c | 3 +--
 fs/btrfs/sysfs.c       | 7 ++++++-
 2 files changed, 7 insertions(+), 3 deletions(-)

-- 
2.21.0


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

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

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13  3:39 [PATCH 0/2] Fix kobject error path memleaks Tobin C. Harding
2019-05-13  3:39 ` [PATCH 1/2] fs: btrfs: Fix error path kobject memory leak Tobin C. Harding
2019-05-13  5:59   ` Nikolay Borisov
2019-05-13  7:11     ` Greg Kroah-Hartman
2019-05-13  3:39 ` [PATCH 2/2] fs: btrfs: Don't leak memory when failing add fsid Tobin C. Harding
2019-05-13  6:04   ` Nikolay Borisov
2019-05-13 10:57     ` Tobin C. Harding
2019-05-13  7:12   ` Greg Kroah-Hartman
2019-05-13 17:47 ` [PATCH 0/2] Fix kobject error path memleaks David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).