linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] blkcg:fixes memory leaks in blkg_conf_prep()
@ 2020-05-15 12:24 Wu Bo
  0 siblings, 0 replies; only message in thread
From: Wu Bo @ 2020-05-15 12:24 UTC (permalink / raw)
  To: tj, axboe
  Cc: cgroups, linux-block, linux-kernel, liuzhiqiang26, linfeilong, wubo40

blkg_conf_prep():
 
new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
...
blkg = blkg_lookup_check(pos, pol, q);
if (IS_ERR(blkg)) {
	ret = PTR_ERR(blkg);
	goto fail_unlock;
}
...


if calling blkg_lookup_check() failed, at the IS_ERR block, 
the new_blkg should be free before goto lable fail_unlock
in blkg_conf_prep() function.

Signed-off-by: Wu Bo <wubo40@huawei.com>
---
 block/blk-cgroup.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 930212c..afeb769 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -682,6 +682,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
 		blkg = blkg_lookup_check(pos, pol, q);
 		if (IS_ERR(blkg)) {
 			ret = PTR_ERR(blkg);
+			blkg_free(new_blkg);
 			goto fail_unlock;
 		}
 
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-05-15 12:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-15 12:24 [PATCH] blkcg:fixes memory leaks in blkg_conf_prep() Wu Bo

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).