* [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm
@ 2023-03-23 1:30 miaoguanqin
0 siblings, 0 replies; 13+ messages in thread
From: miaoguanqin @ 2023-03-23 1:30 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan,we found some memory leaks.
We fix these memory leaks based on code logic.
miaoguanqin (4):
Fix memory leak in file Assemble
Fix memory leak in file Kill
Fix memory leak in file Manage
Fix memory leak in file mdadm
Assemble.c | 15 +++++++++++++--
Kill.c | 9 ++++++++-
Manage.c | 16 +++++++++++++++-
mdadm.c | 4 ++++
4 files changed, 40 insertions(+), 4 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm
@ 2023-04-06 11:40 Guanqin Miao
0 siblings, 0 replies; 13+ messages in thread
From: Guanqin Miao @ 2023-04-06 11:40 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan,i we found some memory leaks.
We fix these memory leaks based on code logic.
Guanqin Miao (4):
Fix memory leak in file Assemble
Fix memory leak in file Kill
Fix memory leak in file Manage
Fix memory leak in file mdadm
Assemble.c | 15 +++++++++++++--
Kill.c | 9 ++++++++-
Manage.c | 15 ++++++++++++++-
mdadm.c | 4 ++++
4 files changed, 39 insertions(+), 4 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm
@ 2023-04-24 8:06 Guanqin Miao
2023-04-24 8:06 ` [PATCH 1/4] Fix memory leak in file Assemble Guanqin Miao
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Guanqin Miao @ 2023-04-24 8:06 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan,i we found some memory leaks.
We fix these memory leaks based on code logic.
Guanqin Miao (4):
Fix memory leak in file Assemble
Fix memory leak in file Kill
Fix memory leak in file Manage
Fix memory leak in file mdadm
Assemble.c | 13 +++++++++++--
Kill.c | 9 ++++++++-
Manage.c | 11 ++++++++++-
mdadm.c | 4 ++++
4 files changed, 33 insertions(+), 4 deletions(-)
--
2.33.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/4] Fix memory leak in file Assemble
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
@ 2023-04-24 8:06 ` Guanqin Miao
2023-08-23 13:43 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 2/4] Fix memory leak in file Kill Guanqin Miao
` (3 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Guanqin Miao @ 2023-04-24 8:06 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan, we found some memory leaks in Assemble.c
We fix these memory leaks based on code logic.
Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
---
Assemble.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/Assemble.c b/Assemble.c
index 49804941..a49de183 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -341,8 +341,10 @@ static int select_devices(struct mddev_dev *devlist,
st->ss->free_super(st);
dev_policy_free(pol);
domain_free(domains);
- if (tst)
+ if (tst) {
tst->ss->free_super(tst);
+ free(tst);
+ }
return -1;
}
@@ -417,6 +419,7 @@ static int select_devices(struct mddev_dev *devlist,
st->ss->free_super(st);
dev_policy_free(pol);
domain_free(domains);
+ free(st);
return -1;
}
if (c->verbose > 0)
@@ -425,6 +428,7 @@ static int select_devices(struct mddev_dev *devlist,
/* make sure we finished the loop */
tmpdev = NULL;
+ free(st);
goto loop;
} else {
content = *contentp;
@@ -533,6 +537,7 @@ static int select_devices(struct mddev_dev *devlist,
st->ss->free_super(st);
dev_policy_free(pol);
domain_free(domains);
+ free(tst);
return -1;
}
tmpdev->used = 1;
@@ -546,8 +551,10 @@ static int select_devices(struct mddev_dev *devlist,
}
dev_policy_free(pol);
pol = NULL;
- if (tst)
+ if (tst) {
tst->ss->free_super(tst);
+ free(tst);
+ }
}
/* Check if we found some imsm spares but no members */
@@ -839,6 +846,7 @@ static int load_devices(struct devs *devices, char *devmap,
close(mdfd);
free(devices);
free(devmap);
+ free(best);
*stp = st;
return -1;
}
@@ -1950,6 +1958,7 @@ out:
} else if (mdfd >= 0)
close(mdfd);
+ free(best);
/* '2' means 'OK, but not started yet' */
if (rv == -1) {
free(devices);
--
2.33.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/4] Fix memory leak in file Kill
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
2023-04-24 8:06 ` [PATCH 1/4] Fix memory leak in file Assemble Guanqin Miao
@ 2023-04-24 8:06 ` Guanqin Miao
2023-08-23 13:49 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
` (2 subsequent siblings)
4 siblings, 1 reply; 13+ messages in thread
From: Guanqin Miao @ 2023-04-24 8:06 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan, we found some memory leaks in Kill.c
We fix these memory leaks based on code logic.
Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
---
Kill.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Kill.c b/Kill.c
index bfd0efdc..43c9abed 100644
--- a/Kill.c
+++ b/Kill.c
@@ -41,6 +41,7 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
* 4 - failed to find a superblock.
*/
+ bool free_super = false;
int fd, rv = 0;
if (force)
@@ -52,8 +53,10 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
dev);
return 2;
}
- if (st == NULL)
+ if (st == NULL) {
st = guess_super(fd);
+ free_super = true;
+ }
if (st == NULL || st->ss->init_super == NULL) {
if (verbose >= 0)
pr_err("Unrecognised md component device - %s\n", dev);
@@ -77,6 +80,10 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
rv = 0;
}
}
+ if (free_super && st) {
+ st->ss->free_super(st);
+ free(st);
+ }
close(fd);
return rv;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/4] Fix memory leak in file Manage
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
2023-04-24 8:06 ` [PATCH 1/4] Fix memory leak in file Assemble Guanqin Miao
2023-04-24 8:06 ` [PATCH 2/4] Fix memory leak in file Kill Guanqin Miao
@ 2023-04-24 8:06 ` Guanqin Miao
2023-08-23 13:50 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 4/4] Fix memory leak in file mdadm Guanqin Miao
2023-09-01 16:02 ` [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Jes Sorensen
4 siblings, 1 reply; 13+ messages in thread
From: Guanqin Miao @ 2023-04-24 8:06 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan, we found some memory leaks in Manage.c
We fix these memory leaks based on code logic.
Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
---
Manage.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/Manage.c b/Manage.c
index f54de7c6..7b6b2798 100644
--- a/Manage.c
+++ b/Manage.c
@@ -222,6 +222,7 @@ 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);
+ sysfs_free(mdi);
return 1;
}
/* If this is an mdmon managed array, just write 'inactive'
@@ -801,8 +802,14 @@ 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) {
+ free(dev_st);
return rv;
+ }
+ }
+ if (dev_st) {
+ dev_st->ss->free_super(dev_st);
+ free(dev_st);
}
}
if (dv->disposition == 'M') {
@@ -1699,6 +1706,7 @@ int Manage_subdevs(char *devname, int fd,
break;
}
}
+ free(tst);
if (frozen > 0)
sysfs_set_str(&info, NULL, "sync_action","idle");
if (test && count == 0)
@@ -1706,6 +1714,7 @@ int Manage_subdevs(char *devname, int fd,
return 0;
abort:
+ free(tst);
if (frozen > 0)
sysfs_set_str(&info, NULL, "sync_action","idle");
return !test && busy ? 2 : 1;
--
2.33.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/4] Fix memory leak in file mdadm
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
` (2 preceding siblings ...)
2023-04-24 8:06 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
@ 2023-04-24 8:06 ` Guanqin Miao
2023-08-23 13:51 ` Mariusz Tkaczyk
2023-09-01 16:02 ` [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Jes Sorensen
4 siblings, 1 reply; 13+ messages in thread
From: Guanqin Miao @ 2023-04-24 8:06 UTC (permalink / raw)
To: jes, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
When we test mdadm with asan, we found some memory leaks in mdadm.c
We fix these memory leaks based on code logic.
Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
---
mdadm.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/mdadm.c b/mdadm.c
index 2296911d..409da62c 100644
--- a/mdadm.c
+++ b/mdadm.c
@@ -1709,6 +1709,10 @@ int main(int argc, char *argv[])
autodetect();
break;
}
+ if (ss) {
+ ss->ss->free_super(ss);
+ free(ss);
+ }
if (locked)
cluster_release_dlmlock();
close_fd(&mdfd);
--
2.33.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 1/4] Fix memory leak in file Assemble
2023-04-24 8:06 ` [PATCH 1/4] Fix memory leak in file Assemble Guanqin Miao
@ 2023-08-23 13:43 ` Mariusz Tkaczyk
0 siblings, 0 replies; 13+ messages in thread
From: Mariusz Tkaczyk @ 2023-08-23 13:43 UTC (permalink / raw)
To: Guanqin Miao
Cc: jes, pmenzel, linux-raid, linfeilong, lixiaokeng, louhongxiang
On Mon, 24 Apr 2023 16:06:34 +0800
Guanqin Miao <miaoguanqin@huawei.com> wrote:
> When we test mdadm with asan, we found some memory leaks in Assemble.c
> We fix these memory leaks based on code logic.
>
> Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
> Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
> ---
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 2/4] Fix memory leak in file Kill
2023-04-24 8:06 ` [PATCH 2/4] Fix memory leak in file Kill Guanqin Miao
@ 2023-08-23 13:49 ` Mariusz Tkaczyk
0 siblings, 0 replies; 13+ messages in thread
From: Mariusz Tkaczyk @ 2023-08-23 13:49 UTC (permalink / raw)
To: Guanqin Miao
Cc: jes, pmenzel, linux-raid, linfeilong, lixiaokeng, louhongxiang
On Mon, 24 Apr 2023 16:06:35 +0800
Guanqin Miao <miaoguanqin@huawei.com> wrote:
> When we test mdadm with asan, we found some memory leaks in Kill.c
> We fix these memory leaks based on code logic.
>
> Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
> Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
> ---
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 3/4] Fix memory leak in file Manage
2023-04-24 8:06 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
@ 2023-08-23 13:50 ` Mariusz Tkaczyk
0 siblings, 0 replies; 13+ messages in thread
From: Mariusz Tkaczyk @ 2023-08-23 13:50 UTC (permalink / raw)
To: Guanqin Miao
Cc: jes, pmenzel, linux-raid, linfeilong, lixiaokeng, louhongxiang
On Mon, 24 Apr 2023 16:06:36 +0800
Guanqin Miao <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.
>
> Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
> Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
> ---
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/4] Fix memory leak in file mdadm
2023-04-24 8:06 ` [PATCH 4/4] Fix memory leak in file mdadm Guanqin Miao
@ 2023-08-23 13:51 ` Mariusz Tkaczyk
0 siblings, 0 replies; 13+ messages in thread
From: Mariusz Tkaczyk @ 2023-08-23 13:51 UTC (permalink / raw)
To: Guanqin Miao
Cc: jes, pmenzel, linux-raid, linfeilong, lixiaokeng, louhongxiang
On Mon, 24 Apr 2023 16:06:37 +0800
Guanqin Miao <miaoguanqin@huawei.com> wrote:
> When we test mdadm with asan, we found some memory leaks in mdadm.c
> We fix these memory leaks based on code logic.
>
> Signed-off-by: Guanqin Miao <miaoguanqin@huawei.com>
> Signed-off-by: Li Xiao Keng <lixiaokeng@huawei.com>
> ---
Acked-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
` (3 preceding siblings ...)
2023-04-24 8:06 ` [PATCH 4/4] Fix memory leak in file mdadm Guanqin Miao
@ 2023-09-01 16:02 ` Jes Sorensen
2023-09-01 16:07 ` Jes Sorensen
4 siblings, 1 reply; 13+ messages in thread
From: Jes Sorensen @ 2023-09-01 16:02 UTC (permalink / raw)
To: Guanqin Miao, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
On 4/24/23 04:06, Guanqin Miao wrote:
> When we test mdadm with asan,i we found some memory leaks.
> We fix these memory leaks based on code logic.
>
> Guanqin Miao (4):
> Fix memory leak in file Assemble
> Fix memory leak in file Kill
> Fix memory leak in file Manage
> Fix memory leak in file mdadm
>
> Assemble.c | 13 +++++++++++--
> Kill.c | 9 ++++++++-
> Manage.c | 11 ++++++++++-
> mdadm.c | 4 ++++
> 4 files changed, 33 insertions(+), 4 deletions(-)
>
I applied this, modulo a fix to the Manage fix, where it would try to
call free(tst) in the abort path, before tst was initialized.
Thanks,
Jes
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm
2023-09-01 16:02 ` [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Jes Sorensen
@ 2023-09-01 16:07 ` Jes Sorensen
0 siblings, 0 replies; 13+ messages in thread
From: Jes Sorensen @ 2023-09-01 16:07 UTC (permalink / raw)
To: Guanqin Miao, mariusz.tkaczyk, pmenzel, linux-raid
Cc: linfeilong, lixiaokeng, louhongxiang
On 9/1/23 12:02, Jes Sorensen wrote:
> On 4/24/23 04:06, Guanqin Miao wrote:
>> When we test mdadm with asan,i we found some memory leaks.
>> We fix these memory leaks based on code logic.
>>
>> Guanqin Miao (4):
>> Fix memory leak in file Assemble
>> Fix memory leak in file Kill
>> Fix memory leak in file Manage
>> Fix memory leak in file mdadm
>>
>> Assemble.c | 13 +++++++++++--
>> Kill.c | 9 ++++++++-
>> Manage.c | 11 ++++++++++-
>> mdadm.c | 4 ++++
>> 4 files changed, 33 insertions(+), 4 deletions(-)
>>
>
> I applied this, modulo a fix to the Manage fix, where it would try to
> call free(tst) in the abort path, before tst was initialized.
Oh and a fix to Assemble where free(st) would goto loop and then
dereference st.
Jes
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-09-01 16:08 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-04-24 8:06 [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Guanqin Miao
2023-04-24 8:06 ` [PATCH 1/4] Fix memory leak in file Assemble Guanqin Miao
2023-08-23 13:43 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 2/4] Fix memory leak in file Kill Guanqin Miao
2023-08-23 13:49 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 3/4] Fix memory leak in file Manage Guanqin Miao
2023-08-23 13:50 ` Mariusz Tkaczyk
2023-04-24 8:06 ` [PATCH 4/4] Fix memory leak in file mdadm Guanqin Miao
2023-08-23 13:51 ` Mariusz Tkaczyk
2023-09-01 16:02 ` [PATCH 0/4] Fix memory leak for Manage Assemble Kill mdadm Jes Sorensen
2023-09-01 16:07 ` Jes Sorensen
-- strict thread matches above, loose matches on Subject: below --
2023-04-06 11:40 Guanqin Miao
2023-03-23 1:30 miaoguanqin
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).