Skip to contentSkip to conversation

blkcg:Fix memory leaks in blkg_conf_prep()

PATCH In review Wu Bo 3 participants 3 messages May 18, 2020 – May 26, 2020

Subsystems (4)
lore
Share & tools
lore

Wu Bo

author
#0 lore raw

PATCH 1/1 blkcg:Fix memory leaks in blkg_conf_prep()

From: Wu Bo <[email protected]>

If a call of the function blkg_lookup_check() failed, we should be release the previously allocated block group before jumping to the lable 'fail_unlock' in the implementation of the function blkg_conf_prep().

---
V2: omit the source code quotation from
the change description

---
 block/blk-cgroup.c | 1 +
 1 file changed, 1 insertion(+)
block/blk-cgroup.c +1 -0
index 930212c..afeb769 100644
@@ -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;
 		}
 
Signature · 1 line
1.8.3.1
#1 lore raw

Re: [PATCH v2] blkcg: Fix memory leak in blkg_conf_prep()

Quoted 1 line

If a call of the function blkg_lookup_check() failed,

Thanks that you would like to integrate something from my suggestion.

Quoted 1 line

we should be release the previously allocated block group

I find that an other wording would be preferred over “we should�.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?id=b9bbe6ed63b2b9f2c9ee5cbd0f2c946a2723f4ce#n151

Quoted 1 line

before jumping to the lable 'fail_unlock' in the implementation of

Please avoid another typo here.

Quoted 3 lines

the function blkg_conf_prep().

I find this tag questionable because the bug fix was presented before.
https://lore.kernel.org/linux-block/[email protected]/
https://lkml.org/lkml/2020/5/15/779

Quoted 3 lines

---
V2: omit the source code quotation from
the change description

* I recommend to improve also the patch subject accordingly.

* Would you like to move the name from the previous tag into this information?

Quoted 2 lines
---
 block/blk-cgroup.c | 1 +

I suggest to omit the triple dashes before this diffstat.

Regards,
Markus

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Wu Bo
Quoted 9 lines · Wu Bo

From: Wu Bo <[email protected]>

If a call of the function blkg_lookup_check() failed, we should be release the previously allocated block group before jumping to the lable 'fail_unlock' in the implementation of the function blkg_conf_prep().

Thanks.

Signature · 1 line
tejun