lkml.org 
[lkml]   [2023]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH -next 3/7] md: don't rely on 'mddev->pers' to be set in mddev_suspend()
Date
From: Yu Kuai <yukuai3@huawei.com>

Now that active io is initialized when mddev is allocated, it's safe to
call mddev_suspend() before 'mddev->pers' is set.

This also prevent null-ptr-def in some cases that caller doesn't
guarantee 'mddev->pers' to be set.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
drivers/md/md.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 897e94a9e47d..f14f2f0a9484 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -448,7 +448,7 @@ void mddev_suspend(struct mddev *mddev)
set_bit(MD_ALLOW_SB_UPDATE, &mddev->flags);
percpu_ref_kill(&mddev->active_io);

- if (mddev->pers->prepare_suspend)
+ if (mddev->pers && mddev->pers->prepare_suspend)
mddev->pers->prepare_suspend(mddev);

wait_event(mddev->sb_wait, percpu_ref_is_zero(&mddev->active_io));
--
2.39.2
\
 
 \ /
  Last update: 2023-08-03 15:34    [W:0.134 / U:0.496 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site