blktests nvme 041,042 leak memory

Keith Busch kbusch at kernel.org
Wed May 29 09:48:42 PDT 2024


On Wed, May 29, 2024 at 10:25:18AM -0600, Keith Busch wrote:
> ---
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index f5d150c62955d..72c9693e1df61 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -4601,7 +4601,8 @@ static void nvme_free_ctrl(struct device *dev)
>  		mutex_unlock(&nvme_subsystems_lock);
>  	}
>  
> -	ctrl->ops->free_ctrl(ctrl);
> +	if (nvme_ctrl_state(ctrl) != NVME_CTRL_NEW)
> +		ctrl->ops->free_ctrl(ctrl);

I think this may be problematic. If nvme_init_ctrl() is successful,
there are other things that might fail before CONNECTING state has been
reached, and those failures need their free_ctrl callback invoked from
the "NEW" state.



More information about the Linux-nvme mailing list