[PATCH v3 2/2] nvme/mpath: fix crash in nvme_mpath_update for non-ana ctrl
Anton Eidelman
anton.eidelman at gmail.com
Wed Mar 23 17:39:00 PDT 2022
When CONFIG_NVME_MULTIPATH is enabled, the nvme_mpath_update()
is called from nvme_start_ctrl()
for both ANA and non-ANA ctrls and regardless of multipath on/off.
Unless multipath is on and the ctrl is ANA-enabled
the function will crash as the initializations
for ANA specific parts of the ctrl are skipped in such cases
in nvme_mpath_init_identify().
Fix: check as done in nvme_handle_aen_notice() for ana_work:
a NULL ctrl->ana_log_buf indicates ctrl does not have ANA.
Fixes: d50c992edf10 ("nvme-multipath: fix hang when disk goes live over reconnect")
Signed-off-by: Anton Eidelman <anton at lightbitslabs.com>
---
drivers/nvme/host/multipath.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index 12d4afde3662..d36f2543ebe1 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -712,11 +712,13 @@ static void nvme_ana_work(struct work_struct *work)
void nvme_mpath_update(struct nvme_ctrl *ctrl)
{
- u32 nr_change_groups = 0;
+ if (ctrl->ana_log_buf) {
+ u32 nr_change_groups = 0;
- mutex_lock(&ctrl->ana_lock);
- nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
- mutex_unlock(&ctrl->ana_lock);
+ mutex_lock(&ctrl->ana_lock);
+ nvme_parse_ana_log(ctrl, &nr_change_groups, nvme_update_ana_state);
+ mutex_unlock(&ctrl->ana_lock);
+ }
}
static void nvme_anatt_timeout(struct timer_list *t)
--
2.25.1
More information about the Linux-nvme
mailing list