On Fri, Dec 10, 2021 at 9:22 AM Guoqing Jiang <guoqing.jiang@xxxxxxxxx> wrote: > > > > On 12/10/21 2:02 AM, Song Liu wrote: > > On Wed, Dec 8, 2021 at 9:55 PM Xiao Ni<xni@xxxxxxxxxx> wrote: > >> It doesn't free memory when register integrity failed. And move > >> free conf codes into a single function. > >> > >> Signed-off-by: Xiao Ni<xni@xxxxxxxxxx> > >> --- > >> drivers/md/raid0.c | 18 +++++++++++++++--- > >> 1 file changed, 15 insertions(+), 3 deletions(-) > >> > >> diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c > >> index 62c8b6adac70..3fa47df1c60e 100644 > >> --- a/drivers/md/raid0.c > >> +++ b/drivers/md/raid0.c > >> @@ -356,6 +356,7 @@ static sector_t raid0_size(struct mddev *mddev, sector_t sectors, int raid_disks > >> return array_sectors; > >> } > >> > >> +static void free_conf(struct r0conf *conf); > >> static void raid0_free(struct mddev *mddev, void *priv); > >> > >> static int raid0_run(struct mddev *mddev) > >> @@ -413,19 +414,30 @@ static int raid0_run(struct mddev *mddev) > >> dump_zones(mddev); > >> > >> ret = md_integrity_register(mddev); > >> + if (ret) > >> + goto free; > >> > >> return ret; > >> + > >> +free: > >> + free_conf(conf); > > Can we just use raid0_free() here? Also, after freeing conf, > > we should set mddev->private to NULL. > > Agree, like what raid1_run did. And we might need to check the > return value of pers->run in level_store as well. Yes. It needs to check the return value and try to reback to the original state. I planed to fix this in the following days not this patch. This patch only fix the NULL reference problem after reshape. In fact, no only we need to check pers->run in level_store, we also need to check integrity during reshape. Now integrity only supports raid0/raid1/raid10, so it needs to do some jobs related with integrity (unregister/register) I plan to fix these two problems in the next patches. Is it OK? Regards Xiao