linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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 4/5 v2] find_disk_attached_hba: fix memleak
Date: Fri, 10 Jun 2022 11:16:22 +0200	[thread overview]
Message-ID: <20220610111622.00007807@linux.intel.com> (raw)
In-Reply-To: <b54a5d8f-f6f4-af57-b54a-74e56f43dbb1@huawei.com>

On Thu, 9 Jun 2022 11:08:39 +0800
Wu Guanghao <wuguanghao3@huawei.com> wrote:

> If disk_path = diskfd_to_devpath(), we need free(disk_path) before
> return, otherwise there will be a memory leak
> 
> Reported-by: Coverity
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
> ---
>  super-intel.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/super-intel.c b/super-intel.c
> index ee9e112e..e94f3f65 100644
> --- a/super-intel.c
> +++ b/super-intel.c
> @@ -701,12 +701,12 @@ static struct sys_dev* find_disk_attached_hba(int fd,
> const char *devname)
> 
>         for (elem = list; elem; elem = elem->next)
>                 if (path_attached_to_hba(disk_path, elem->path))
> -                       return elem;
> +                       break;
> 
>         if (disk_path != devname)
>                 free(disk_path);
> 
> -       return NULL;
> +       return elem;
>  }
> 
>  static int find_intel_hba_capability(int fd, struct intel_super *super,
> --
> 2.27.0

Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>

  reply	other threads:[~2022-06-10  9:19 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
2022-06-09  3:08 ` [PATCH 4/5 v2] find_disk_attached_hba: fix memleak Wu Guanghao
2022-06-10  9:16   ` Mariusz Tkaczyk [this message]
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 4/5 v2] find_disk_attached_hba: fix memleak Wu Guanghao
2022-09-03  8:37   ` 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=20220610111622.00007807@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 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).