[PATCH] nvme: initialize identify ns data to NULL

Keith Busch kbusch at kernel.org
Tue Mar 26 08:37:07 PDT 2024


On Tue, Mar 26, 2024 at 12:45:03AM +0900, Tokunori Ikegami wrote:
>  static int ns_head_update_nuse(struct nvme_ns_head *head)
>  {
> -	struct nvme_id_ns *id;
> +	struct nvme_id_ns *id = NULL;
>  	struct nvme_ns *ns;
>  	int srcu_idx, ret = -EWOULDBLOCK;

This is a redundant setting. The first thing that happens to "id" is
reference passed to nvme_identify_ns, and the first thing it does is
this:

	*id = kmalloc(sizeof(**id), GFP_KERNEL);

So either kmalloc succeeds and overwrites your NULL setting, or malloc
fails and sets it to NULL again.



More information about the Linux-nvme mailing list