[PATCH] nvme: host: fix double-free of struct nvme_id_ns in ns_update_nuse()

Shinichiro Kawasaki shinichiro.kawasaki at wdc.com
Tue Mar 5 21:58:25 PST 2024


On Mar 06, 2024 / 05:32, Chaitanya Kulkarni wrote:
[...]
> instead of adding a label that is only used once, why not just return ?

That's right. Will post v2.

> something like this totally untested :-
> 
> diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c
> index d099218e494a..9e12b66c4405 100644
> --- a/drivers/nvme/host/sysfs.c
> +++ b/drivers/nvme/host/sysfs.c
> @@ -221,11 +221,10 @@ static int ns_update_nuse(struct nvme_ns *ns)
> 
>          ret = nvme_identify_ns(ns->ctrl, ns->head->ns_id, &id);
>          if (ret)
> -               goto out_free_id;
> +               return ret;
> 
>          ns->head->nuse = le64_to_cpu(id->nuse);
> 
> -out_free_id:
>          kfree(id);
> 
>          return ret;
> 
> 
> -ck
> 
> 


More information about the Linux-nvme mailing list