From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753019AbdLDHKg (ORCPT ); Mon, 4 Dec 2017 02:10:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60076 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750897AbdLDHKf (ORCPT ); Mon, 4 Dec 2017 02:10:35 -0500 Subject: Re: [PATCH net] virtio_net: fix return value check in receive_mergeable() To: wangyunjian , linux-kernel@vger.kernel.org Cc: mst@redhat.com, caihe@huawei.com References: <1512367339-19000-1-git-send-email-wangyunjian@huawei.com> From: Jason Wang Message-ID: Date: Mon, 4 Dec 2017 15:10:28 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <1512367339-19000-1-git-send-email-wangyunjian@huawei.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 04 Dec 2017 07:10:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2017年12月04日 14:02, wangyunjian wrote: > From: Yunjian Wang > > 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 > --- > 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