[PATCH 3/3] nvme-core: fix crash when nvme_enable_aen timeout
Sagi Grimberg
sagi at grimberg.me
Thu Aug 20 00:30:22 EDT 2020
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 74f76aa78b02..f4c347fe925a 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -1422,21 +1422,25 @@ EXPORT_SYMBOL_GPL(nvme_set_queue_count);
> (NVME_AEN_CFG_NS_ATTR | NVME_AEN_CFG_FW_ACT | \
> NVME_AEN_CFG_ANA_CHANGE | NVME_AEN_CFG_DISC_CHANGE)
>
> -static void nvme_enable_aen(struct nvme_ctrl *ctrl)
> +static int nvme_enable_aen(struct nvme_ctrl *ctrl)
> {
> u32 result, supported_aens = ctrl->oaes & NVME_AEN_SUPPORTED;
> int status;
>
> if (!supported_aens)
> - return;
> + return 0;
>
> status = nvme_set_features(ctrl, NVME_FEAT_ASYNC_EVENT, supported_aens,
> NULL, 0, &result);
> - if (status)
> + if (status) {
> dev_warn(ctrl->device, "Failed to configure AEN (cfg %x)\n",
> supported_aens);
> + if (status < 0)
> + return status;
Why do you need to check status < 0, you need to fail it regardless.
More information about the Linux-nvme
mailing list