From efeedddcb58c29eea1bfc076f46f73e34e9f6656 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 7 Apr 2020 03:19:00 +0000 Subject: [PATCH] Fix panic on kern.cam.ctl.ha_role change after r333446. MFC after: 1 week Sponsored by: iXsystems, Inc. --- sys/cam/ctl/ctl_backend_block.c | 6 ++++-- sys/cam/ctl/ctl_backend_ramdisk.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sys/cam/ctl/ctl_backend_block.c b/sys/cam/ctl/ctl_backend_block.c index c1c9881efd94..6323c47271f5 100644 --- a/sys/cam/ctl/ctl_backend_block.c +++ b/sys/cam/ctl/ctl_backend_block.c @@ -2574,8 +2574,10 @@ ctl_be_block_modify(struct ctl_be_block_softc *softc, struct ctl_lun_req *req) if (params->lun_size_bytes != 0) be_lun->params.lun_size_bytes = params->lun_size_bytes; - nvlist_destroy(cbe_lun->options); - cbe_lun->options = nvlist_clone(req->args_nvl); + if (req->args_nvl != NULL) { + nvlist_destroy(cbe_lun->options); + cbe_lun->options = nvlist_clone(req->args_nvl); + } wasprim = (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY); value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL); diff --git a/sys/cam/ctl/ctl_backend_ramdisk.c b/sys/cam/ctl/ctl_backend_ramdisk.c index c0f190cc931a..52c983080a7e 100644 --- a/sys/cam/ctl/ctl_backend_ramdisk.c +++ b/sys/cam/ctl/ctl_backend_ramdisk.c @@ -1252,8 +1252,10 @@ ctl_backend_ramdisk_modify(struct ctl_be_ramdisk_softc *softc, if (params->lun_size_bytes != 0) be_lun->params.lun_size_bytes = params->lun_size_bytes; - nvlist_destroy(cbe_lun->options); - cbe_lun->options = nvlist_clone(req->args_nvl); + if (req->args_nvl != NULL) { + nvlist_destroy(cbe_lun->options); + cbe_lun->options = nvlist_clone(req->args_nvl); + } wasprim = (cbe_lun->flags & CTL_LUN_FLAG_PRIMARY); value = dnvlist_get_string(cbe_lun->options, "ha_role", NULL);