[PATCH] nvme: Fix NULL dereference for pci nvme controllers

Keith Busch kbusch at kernel.org
Mon Aug 24 18:58:29 EDT 2020


On Mon, Aug 24, 2020 at 03:56:56PM -0700, Sagi Grimberg wrote:
> PCIe controllers do not have fabric opts, verify they exist before
> showing ctrl_loss_tmo or reconnect_delay attributes.
> 
> Fixes: 764075fdcb2f ("nvme: expose reconnect_delay and ctrl_loss_tmo via sysfs")
> Reported-by: Tobias Markus <tobias at markus-regensburg.de>
> Signed-off-by: Sagi Grimberg <sagi at grimberg.me>
> ---
>  drivers/nvme/host/core.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 537dcd900cb5..e406c3cf55bc 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3676,6 +3676,10 @@ static umode_t nvme_dev_attrs_are_visible(struct kobject *kobj,
>  		return 0;
>  	if (a == &dev_attr_hostid.attr && !ctrl->opts)
>  		return 0;
> +	if (a == &dev_attr_ctrl_loss_tmo.attr && !ctrl->opts)
> +		return 0;
> +	if (a == &dev_attr_reconnect_delay.attr && !ctrl->opts)
> +		return 0;
>  
>  	return a->mode;
>  }

And you'd already fixed up the duplicate line in the real patch.

Reviewed-by: Keith Busch <kbusch at kernel.org>



More information about the Linux-nvme mailing list