lkml.org 
[lkml]   [2016]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] virtio_ring: fix complaint by sparse
On Tue, Nov 22, 2016 at 7:16 AM, Thomas Huth <thuth@redhat.com> wrote:
> On 22.11.2016 16:04, Michael S. Tsirkin wrote:
>> On Tue, Nov 22, 2016 at 01:51:50PM +0800, Gonglei wrote:
>>> # make C=2 CF="-D__CHECK_ENDIAN__" ./drivers/virtio/
>>>
>>> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
>>> drivers/virtio/virtio_ring.c:423:19: expected unsigned int [unsigned] [assigned] i
>>> drivers/virtio/virtio_ring.c:423:19: got restricted __virtio16 [usertype] next
>>> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
>>> drivers/virtio/virtio_ring.c:423:19: expected unsigned int [unsigned] [assigned] i
>>> drivers/virtio/virtio_ring.c:423:19: got restricted __virtio16 [usertype] next
>>> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
>>> drivers/virtio/virtio_ring.c:423:19: expected unsigned int [unsigned] [assigned] i
>>> drivers/virtio/virtio_ring.c:423:19: got restricted __virtio16 [usertype] next
>>> drivers/virtio/virtio_ring.c:604:39: warning: incorrect type in initializer (different base types)
>>> drivers/virtio/virtio_ring.c:604:39: expected unsigned short [unsigned] [usertype] nextflag
>>> drivers/virtio/virtio_ring.c:604:39: got restricted __virtio16
>>> drivers/virtio/virtio_ring.c:612:33: warning: restricted __virtio16 degrades to integer
>>>
>>> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
>>> ---
>>> drivers/virtio/virtio_ring.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
>>> index 489bfc6..d2863c3 100644
>>> --- a/drivers/virtio/virtio_ring.c
>>> +++ b/drivers/virtio/virtio_ring.c
>>> @@ -420,7 +420,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>>> if (i == err_idx)
>>> break;
>>> vring_unmap_one(vq, &desc[i]);
>>> - i = vq->vring.desc[i].next;
>>> + i = virtio16_to_cpu(_vq->vdev, vq->vring.desc[i].next);
>>> }
>>>
>>> vq->vq.num_free += total_sg;
> [...]
>> Wow are you saying endian-ness is all wrong for the next field?
>> How do things ever work then?
>
> The above code is only in the error cleanup path (after the
> "unmap_release" label, introduced by commit 780bc7903), so it likely has
> never been exercised in the field.
> I think Gonlei's patch is right, there should be a virtio16_to_cpu() here.

Agreed.

>
> Thomas
>
>



--
Andy Lutomirski
AMA Capital Management, LLC

\
 
 \ /
  Last update: 2016-11-22 18:26    [W:0.055 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site