diff mbox series

blkcg:Fix memory leaks in blkg_conf_prep()

Message ID 1589805366-328489-1-git-send-email-wubo40@huawei.com (mailing list archive)
State New, archived
Headers show
Series blkcg:Fix memory leaks in blkg_conf_prep() | expand

Commit Message

Wu Bo May 18, 2020, 12:36 p.m. UTC
From: Wu Bo <wubo40@huawei.com>

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

Suggested-by: Markus Elfring <Markus.Elfring@web.de>
Signed-off-by: Wu Bo <wubo40@huawei.com>

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

---
 block/blk-cgroup.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Markus Elfring May 18, 2020, 2:06 p.m. UTC | #1
> If a call of the function blkg_lookup_check() failed,

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


> 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


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

Please avoid another typo here.


> the function blkg_conf_prep().
>
> Suggested-by: Markus Elfring <Markus.Elfring@web.de>

I find this tag questionable because the bug fix was presented before.
https://lore.kernel.org/linux-block/4c670a6c-98c3-2b14-7438-09199506d92f@web.de/
https://lkml.org/lkml/2020/5/15/779


> ---
> 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?


> ---
>  block/blk-cgroup.c | 1 +

I suggest to omit the triple dashes before this diffstat.

Regards,
Markus
Tejun Heo May 26, 2020, 5:23 p.m. UTC | #2
On Mon, May 18, 2020 at 08:36:06PM +0800, Wu Bo wrote:
> From: Wu Bo <wubo40@huawei.com>
> 
> 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().
> 
> Suggested-by: Markus Elfring <Markus.Elfring@web.de>
> Signed-off-by: Wu Bo <wubo40@huawei.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.
diff mbox series

Patch

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;
 		}