All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] virtio_net: fix return value check in receive_mergeable()
@ 2017-12-04  6:02 wangyunjian
  2017-12-04  7:10 ` Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: wangyunjian @ 2017-12-04  6:02 UTC (permalink / raw)
  To: linux-kernel; +Cc: mst, jasowang, caihe, Yunjian Wang

From: Yunjian Wang <wangyunjian@huawei.com>

The function virtqueue_get_buf_ctx() could return NULL, the return
value 'buf' need to be checked with NULL, not value 'ctx'.

Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 19a985e..559b215 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -756,7 +756,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
 		int num_skb_frags;
 
 		buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx);
-		if (unlikely(!ctx)) {
+		if (unlikely(!buf)) {
 			pr_debug("%s: rx error: %d buffers out of %d missing\n",
 				 dev->name, num_buf,
 				 virtio16_to_cpu(vi->vdev,
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] virtio_net: fix return value check in receive_mergeable()
  2017-12-04  6:02 [PATCH net] virtio_net: fix return value check in receive_mergeable() wangyunjian
@ 2017-12-04  7:10 ` Jason Wang
  2017-12-04 11:25   ` wangyunjian
  0 siblings, 1 reply; 4+ messages in thread
From: Jason Wang @ 2017-12-04  7:10 UTC (permalink / raw)
  To: wangyunjian, linux-kernel; +Cc: mst, caihe



On 2017年12月04日 14:02, wangyunjian wrote:
> From: Yunjian Wang <wangyunjian@huawei.com>
>
> The function virtqueue_get_buf_ctx() could return NULL, the return
> value 'buf' need to be checked with NULL, not value 'ctx'.
>
> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> ---
>   drivers/net/virtio_net.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 19a985e..559b215 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -756,7 +756,7 @@ static struct sk_buff *receive_mergeable(struct net_device *dev,
>   		int num_skb_frags;
>   
>   		buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx);
> -		if (unlikely(!ctx)) {
> +		if (unlikely(!buf)) {
>   			pr_debug("%s: rx error: %d buffers out of %d missing\n",
>   				 dev->name, num_buf,
>   				 virtio16_to_cpu(vi->vdev,

Hi:

The path looks good but I'm not sure this is a real fix since we add 
data and ctx simultaneously in virtqueue_add_inbuf_ctx().

Any bad result you see without this patch?

Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH net] virtio_net: fix return value check in receive_mergeable()
  2017-12-04  7:10 ` Jason Wang
@ 2017-12-04 11:25   ` wangyunjian
  2017-12-05  2:59     ` Jason Wang
  0 siblings, 1 reply; 4+ messages in thread
From: wangyunjian @ 2017-12-04 11:25 UTC (permalink / raw)
  To: Jason Wang, linux-kernel; +Cc: mst, caihe



> -----Original Message-----
> From: Jason Wang [mailto:jasowang@redhat.com]
> Sent: Monday, December 04, 2017 3:10 PM
> To: wangyunjian <wangyunjian@huawei.com>; linux-
> kernel@vger.kernel.org
> Cc: mst@redhat.com; caihe <caihe@huawei.com>
> Subject: Re: [PATCH net] virtio_net: fix return value check in
> receive_mergeable()
> 
> 
> 
> On 2017年12月04日 14:02, wangyunjian wrote:
> > From: Yunjian Wang <wangyunjian@huawei.com>
> >
> > The function virtqueue_get_buf_ctx() could return NULL, the return
> > value 'buf' need to be checked with NULL, not value 'ctx'.
> >
> > Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
> > ---
> >   drivers/net/virtio_net.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> > index 19a985e..559b215 100644
> > --- a/drivers/net/virtio_net.c
> > +++ b/drivers/net/virtio_net.c
> > @@ -756,7 +756,7 @@ static struct sk_buff *receive_mergeable(struct
> net_device *dev,
> >   		int num_skb_frags;
> >
> >   		buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx);
> > -		if (unlikely(!ctx)) {
> > +		if (unlikely(!buf)) {
> >   			pr_debug("%s: rx error: %d buffers out of %d
> missing\n",
> >   				 dev->name, num_buf,
> >   				 virtio16_to_cpu(vi->vdev,
> 
> Hi:
> 
> The path looks good but I'm not sure this is a real fix since we add
> data and ctx simultaneously in virtqueue_add_inbuf_ctx().
> 
> Any bad result you see without this patch?
> 

Now no problem has been found yet, and I found it when reviewing the code.

Thanks

> Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] virtio_net: fix return value check in receive_mergeable()
  2017-12-04 11:25   ` wangyunjian
@ 2017-12-05  2:59     ` Jason Wang
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Wang @ 2017-12-05  2:59 UTC (permalink / raw)
  To: wangyunjian, linux-kernel; +Cc: mst, caihe



On 2017年12月04日 19:25, wangyunjian wrote:
>
>> -----Original Message-----
>> From: Jason Wang [mailto:jasowang@redhat.com]
>> Sent: Monday, December 04, 2017 3:10 PM
>> To: wangyunjian <wangyunjian@huawei.com>; linux-
>> kernel@vger.kernel.org
>> Cc: mst@redhat.com; caihe <caihe@huawei.com>
>> Subject: Re: [PATCH net] virtio_net: fix return value check in
>> receive_mergeable()
>>
>>
>>
>> On 2017年12月04日 14:02, wangyunjian wrote:
>>> From: Yunjian Wang <wangyunjian@huawei.com>
>>>
>>> The function virtqueue_get_buf_ctx() could return NULL, the return
>>> value 'buf' need to be checked with NULL, not value 'ctx'.
>>>
>>> Signed-off-by: Yunjian Wang <wangyunjian@huawei.com>
>>> ---
>>>    drivers/net/virtio_net.c | 2 +-
>>>    1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>>> index 19a985e..559b215 100644
>>> --- a/drivers/net/virtio_net.c
>>> +++ b/drivers/net/virtio_net.c
>>> @@ -756,7 +756,7 @@ static struct sk_buff *receive_mergeable(struct
>> net_device *dev,
>>>    		int num_skb_frags;
>>>
>>>    		buf = virtqueue_get_buf_ctx(rq->vq, &len, &ctx);
>>> -		if (unlikely(!ctx)) {
>>> +		if (unlikely(!buf)) {
>>>    			pr_debug("%s: rx error: %d buffers out of %d
>> missing\n",
>>>    				 dev->name, num_buf,
>>>    				 virtio16_to_cpu(vi->vdev,
>> Hi:
>>
>> The path looks good but I'm not sure this is a real fix since we add
>> data and ctx simultaneously in virtqueue_add_inbuf_ctx().
>>
>> Any bad result you see without this patch?
>>
> Now no problem has been found yet, and I found it when reviewing the code.
>
> Thanks

Then I think it's better to go net-next. Michael, any idea on this?

Thanks

>
>> Thanks

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-12-05  2:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-04  6:02 [PATCH net] virtio_net: fix return value check in receive_mergeable() wangyunjian
2017-12-04  7:10 ` Jason Wang
2017-12-04 11:25   ` wangyunjian
2017-12-05  2:59     ` Jason Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.