mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: 赵军奎 <bernard@vivo.com>
To: Song Liu <song@kernel.org>
Cc: linux-raid <linux-raid@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: 答复: [PATCH] drivers/md: fix potential memleak
Date: Wed, 17 Nov 2021 07:57:39 +0000	[thread overview]
Message-ID: <PSAPR06MB40216A2C236343B2300EFC48DF9A9@PSAPR06MB4021.apcprd06.prod.outlook.com> (raw)
In-Reply-To: <AE6ABwAlE-AV3TdOtnvxCKoI.9.1637132794891.Hmail.bernard@vivo.com.@PENBUGhzdVc2dWk9d0JyVG9Za3FFT3BMeUxZaGpITW95MG1MMFVNY1hucTBPYktMTGhvQUBtYWlsLmdtYWlsLmNvbT4=>



-----邮件原件-----
发件人: bernard@vivo.com <bernard@vivo.com> 代表 Song Liu
发送时间: 2021年11月17日 15:06
收件人: 赵军奎 <bernard@vivo.com>
抄送: linux-raid <linux-raid@vger.kernel.org>; open list <linux-kernel@vger.kernel.org>
主题: Re: [PATCH] drivers/md: fix potential memleak

On Sun, Nov 14, 2021 at 7:18 PM Bernard Zhao <bernard@vivo.com> wrote:
>
> In function get_bitmap_from_slot, when md_bitmap_create failed, 
> md_bitmap_destroy must be called to do clean up.

>Could you please explain which variable(s) need clean up?

Hi Song:
The follow is the function md_bitmap_create`s annotation :
/*
 * initialize the bitmap structure
 * if this returns an error, bitmap_destroy must be called to do clean up
 * once mddev->bitmap is set
 */
struct bitmap *md_bitmap_create(struct mddev *mddev, int slot)

It is mentioned that bitmap_destroy needs to be called to do clean up.
Other functions which called md_bitmap_create in the same file also called md_bitmap_create to clean up(in the error branch), but this one didn`t.
I am not sure if there is some gap?
Thanks!
BR//Bernard

>Thanks,
>Song

>
> Signed-off-by: Bernard Zhao <bernard@vivo.com>
> ---
>  drivers/md/md-bitmap.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 
> bfd6026d7809..a227bd0b9301 100644
> --- a/drivers/md/md-bitmap.c
> +++ b/drivers/md/md-bitmap.c
> @@ -1961,6 +1961,7 @@ struct bitmap *get_bitmap_from_slot(struct mddev *mddev, int slot)
>         bitmap = md_bitmap_create(mddev, slot);
>         if (IS_ERR(bitmap)) {
>                 rv = PTR_ERR(bitmap);
> +               md_bitmap_destroy(mddev)
>                 return ERR_PTR(rv);
>         }
>
> --
> 2.33.1
>

  parent reply	other threads:[~2021-11-17  7:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-15  3:18 Bernard Zhao
2021-11-17  7:06 ` Song Liu
     [not found] ` <AE6ABwAlE-AV3TdOtnvxCKoI.9.1637132794891.Hmail.bernard@vivo.com.@PENBUGhzdVc2dWk9d0JyVG9Za3FFT3BMeUxZaGpITW95MG1MMFVNY1hucTBPYktMTGhvQUBtYWlsLmdtYWlsLmNvbT4=>
2021-11-17  7:57   ` 赵军奎 [this message]
2021-11-20  7:23     ` Song Liu
2021-11-17 16:44 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PSAPR06MB40216A2C236343B2300EFC48DF9A9@PSAPR06MB4021.apcprd06.prod.outlook.com \
    --to=bernard@vivo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=song@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®