On Thu, 23 Mar 2023 09:30:52 +0800 miaoguanqin <miaoguanqin@xxxxxxxxxx> 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@xxxxxxxxxx> > Signed-off-by: lixiaokeng <lixiaokeng@xxxxxxxxxx> > --- > 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.