All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
To: miaoguanqin <miaoguanqin@huawei.com>
Cc: <jes@trained-monkey.org>, <pmenzel@molgen.mpg.de>,
	<linux-raid@vger.kernel.org>, <linfeilong@huawei.com>,
	<lixiaokeng@huawei.com>, <louhongxiang@huawei.com>
Subject: Re: [PATCH 3/4] Fix memory leak in file Manage
Date: Tue, 28 Mar 2023 12:28:46 +0200	[thread overview]
Message-ID: <20230328122846.00005a5b@linux.intel.com> (raw)
In-Reply-To: <20230323013053.3238005-4-miaoguanqin@huawei.com>

On Thu, 23 Mar 2023 09:30:52 +0800
miaoguanqin <miaoguanqin@huawei.com> wrote:

> When we test mdadm with asan,we found some memory leaks in Manage.c
> We fix these memory leaks based on code logic.

Missing space after comma.
> 
> Signed-off-by: miaoguanqin <miaoguanqin@huawei.com>
> Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
> ---
>  Manage.c | 16 +++++++++++++++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/Manage.c b/Manage.c
> index fde6aba3..75bed83b 100644
> --- a/Manage.c
> +++ b/Manage.c
> @@ -222,6 +222,8 @@ int Manage_stop(char *devname, int fd, int verbose, int
> will_retry) if (verbose >= 0)
>  			pr_err("Cannot get exclusive access to %s:Perhaps a
> running process, mounted filesystem or active volume group?\n", devname);
> +		if (mdi)
> +			sysfs_free(mdi);
>  		return 1;
>  	}
>  	/* If this is an mdmon managed array, just write 'inactive'
> @@ -818,8 +820,16 @@ int Manage_add(int fd, int tfd, struct mddev_dev *dv,
>  						    rdev, update, devname,
>  						    verbose, array);
>  				dev_st->ss->free_super(dev_st);
> -				if (rv)
> +				if (rv) {
> +					if (dev_st)
> +						free(dev_st);

We are calling dev_st->ss->free_super(dev_st) in this code branch so it seems
that dev_st cannot be null, just free is needed.




  reply	other threads:[~2023-03-28 10:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-23  1:30 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm miaoguanqin
2023-03-23  1:30 ` [PATCH 1/4] Fix memory leak in file Assemble miaoguanqin
2023-03-28  7:54   ` Mariusz Tkaczyk
2023-03-28 11:21   ` Paul Menzel
2023-03-23  1:30 ` [PATCH 2/4] Fix memory leak in file Kill miaoguanqin
2023-03-28  9:38   ` Mariusz Tkaczyk
2023-03-23  1:30 ` [PATCH 3/4] Fix memory leak in file Manage miaoguanqin
2023-03-28 10:28   ` Mariusz Tkaczyk [this message]
2023-03-23  1:30 ` [PATCH 4/4] Fix memory leak in file mdadm miaoguanqin
2023-03-28 10:29   ` Mariusz Tkaczyk
2023-04-06 11:40 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
2023-04-06 11:40 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
2023-04-10 15:55   ` Jes Sorensen
2023-04-24  8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
2023-04-24  8:06 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
2023-08-23 13:50   ` Mariusz Tkaczyk

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=20230328122846.00005a5b@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=louhongxiang@huawei.com \
    --cc=miaoguanqin@huawei.com \
    --cc=pmenzel@molgen.mpg.de \
    /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.