Re: [patch] virtio-blk: fix NULL checking in virtblk_alloc_req()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 09/06/2012 10:55 AM, Rusty Russell wrote:
> Dan Carpenter <dan.carpenter@xxxxxxxxxx> writes:
> 
>> Smatch complains about the inconsistent NULL checking here.  Fix it to
>> return NULL on failure.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
>> ---
>> This is only needed in linux-next.
> 
> Nice!
> 
>> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
>> index 2edfb5c..457db0c 100644
>> --- a/drivers/block/virtio_blk.c
>> +++ b/drivers/block/virtio_blk.c
>> @@ -90,10 +90,11 @@ static inline struct virtblk_req *virtblk_alloc_req(struct virtio_blk *vblk,
>>  	struct virtblk_req *vbr;
>>  
>>  	vbr = mempool_alloc(vblk->pool, gfp_mask);
>> -	if (vbr && use_bio)
>> -		sg_init_table(vbr->sg, vblk->sg_elems);
>> +	if (!vbr)
>> +		return NULL;
>>  
>> -	vbr->vblk = vblk;
>> +	if (use_bio)
>> +		sg_init_table(vbr->sg, vblk->sg_elems);
>>  
>>  	return vbr;
>>  }
> 
> But it turns out that "vbr->vblk = vblk;" assignment is important :)

I was just replying ;-)

> Fixed and applied,

Thanks Rusty!

-- 
Asias
_______________________________________________
Virtualization mailing list
Virtualization@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[Index of Archives]     [KVM Development]     [Libvirt Development]     [Libvirt Users]     [CentOS Virtualization]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux