lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 6 Sep 2021 08:16:35 +0200
From:   Hannes Reinecke <hare@...e.de>
To:     Luis Chamberlain <mcgrof@...nel.org>, axboe@...nel.dk,
        martin.petersen@...cle.com, jejb@...ux.ibm.com, kbusch@...nel.org,
        sagi@...mberg.me, adrian.hunter@...el.com, beanhuo@...ron.com,
        ulf.hansson@...aro.org, avri.altman@....com, swboyd@...omium.org,
        agk@...hat.com, snitzer@...hat.com, josef@...icpanda.com
Cc:     hch@...radead.org, bvanassche@....org, ming.lei@...hat.com,
        linux-scsi@...r.kernel.org, linux-nvme@...ts.infradead.org,
        linux-mmc@...r.kernel.org, dm-devel@...hat.com,
        nbd@...er.debian.org, linux-block@...r.kernel.org,
        linux-kernel@...r.kernel.org, Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v3 3/8] nvme: add error handling support for add_disk()

On 8/30/21 11:25 PM, Luis Chamberlain wrote:
> We never checked for errors on add_disk() as this function
> returned void. Now that this is fixed, use the shiny new
> error handling.
> 
> Reviewed-by: Christoph Hellwig <hch@....de>
> Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
> ---
>   drivers/nvme/host/core.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 8679a108f571..687d3be563a3 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -3763,7 +3763,9 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
>   
>   	nvme_get_ctrl(ctrl);
>   
> -	device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups);
> +	if (device_add_disk(ctrl->device, ns->disk, nvme_ns_id_attr_groups))
> +		goto out_cleanup_ns_from_list;
> +
>   	if (!nvme_ns_head_multipath(ns->head))
>   		nvme_add_ns_cdev(ns);
>   
> @@ -3773,6 +3775,11 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid,
>   
>   	return;
>   
> + out_cleanup_ns_from_list:
> +	nvme_put_ctrl(ctrl);
> +	down_write(&ctrl->namespaces_rwsem);
> +	list_del_init(&ns->list);
> +	up_write(&ctrl->namespaces_rwsem);
>    out_unlink_ns:
>   	mutex_lock(&ctrl->subsys->lock);
>   	list_del_rcu(&ns->siblings);
> 
I would rather turn this around, and call 'nvme_put_ctrl()' after 
removing the namespace from the list. But it's probably more a style 
issue, come to think of it.

Reviewed-by: Hannes Reinecke <hare@...e.de>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke                Kernel Storage Architect
hare@...e.de                              +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Felix Imendörffer

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ