From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: Wu Guanghao <wuguanghao3@huawei.com>
Cc: <jes@trained-monkey.org>, <linux-raid@vger.kernel.org>,
Paul Menzel <pmenzel@molgen.mpg.de>, <linfeilong@huawei.com>,
<lixiaokeng@huawei.com>
Subject: Re: [PATCH 3/5 v2] load_imsm_mpb: fix double free
Date: Fri, 10 Jun 2022 11:14:26 +0200 [thread overview]
Message-ID: <20220610111426.00003a45@linux.intel.com> (raw)
In-Reply-To: <3a17cad1-928b-2f44-88e6-df457102cfb2@huawei.com>
On Thu, 9 Jun 2022 11:07:56 +0800
Wu Guanghao <wuguanghao3@huawei.com> wrote:
> When free(super->buf) but not set super->buf = NULL, will be double free.
>
> get_super_block
> err = load_and_parse_mpb
> load_imsm_mpb(.., s, ..)
> if (posix_memalign(&super->buf, MAX_SECTOR_SIZE,
> super->len) != 0) // true, super->buf != NULL if
> (posix_memalign(&super->migr_rec_buf, MAX_SECTOR_SIZE,); // false
> free(super->buf); //but super->buf not set NULL return 2;
>
> if err ! = 0
> if (s)
> free_imsm(s)
> __free_imsm(s)
> if (s)
> free(s->buf); //double free
>
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
> ---
> super-intel.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/super-intel.c b/super-intel.c
> index ba3bd41f..ee9e112e 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -4453,6 +4453,7 @@ static int load_imsm_mpb(int fd, struct intel_super
> *super, char *devname) MIGR_REC_BUF_SECTORS*MAX_SECTOR_SIZE) != 0) {
> pr_err("could not allocate migr_rec buffer\n");
> free(super->buf);
> + super->buf = NULL;
> return 2;
> }
> super->clean_migration_record_by_mdmon = 0;
> --
> 2.27.0
Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
next prev parent reply other threads:[~2022-06-10 9:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-09 3:05 [PATCH 0/5 v2] mdadm: fix memory leak and double free Wu Guanghao
2022-06-09 3:06 ` [PATCH 1/5 v2] parse_layout_faulty: fix memleak Wu Guanghao
2022-06-10 9:13 ` Mariusz Tkaczyk
2022-07-28 21:15 ` Jes Sorensen
2022-08-01 8:07 ` Wu Guanghao
2022-06-09 3:06 ` [PATCH 2/5 v2] Detail: " Wu Guanghao
2022-06-20 17:04 ` Coly Li
2022-06-09 3:07 ` [PATCH 3/5 v2] load_imsm_mpb: fix double free Wu Guanghao
2022-06-10 9:14 ` Mariusz Tkaczyk [this message]
2022-06-09 3:08 ` [PATCH 4/5 v2] find_disk_attached_hba: fix memleak Wu Guanghao
2022-06-10 9:16 ` Mariusz Tkaczyk
2022-06-09 3:09 ` [PATCH 5/5 v2] get_vd_num_of_subarray: " Wu Guanghao
-- strict thread matches above, loose matches on Subject: below --
2022-08-02 2:14 [PATCH 0/5 v2 resend] mdadm: fix memory leak and double free Wu Guanghao
2022-08-02 2:16 ` [PATCH 3/5 v2] load_imsm_mpb: fix " Wu Guanghao
2022-09-03 8:38 ` Coly Li
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=20220610111426.00003a45@linux.intel.com \
--to=mariusz.tkaczyk@linux.intel.com \
--cc=jes@trained-monkey.org \
--cc=linfeilong@huawei.com \
--cc=linux-raid@vger.kernel.org \
--cc=lixiaokeng@huawei.com \
--cc=pmenzel@molgen.mpg.de \
--cc=wuguanghao3@huawei.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.