[PATCH] nvme: initialize identify ns data to NULL

Tokunori Ikegami ikegami.t at gmail.com
Tue Mar 26 08:54:20 PDT 2024


Okay I see. The nvme_identify_ns_nvm() version only sets the memory 
allocated to the output parameter nvmp before the return success so if 
the nvme_identify_ns() also changed as same the NULL initialization 
works correctly. Thank you.

On 2024/03/27 0:37, Keith Busch wrote:
> 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