Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp342050pxf; Thu, 18 Mar 2021 01:21:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjbXjdrNKcA0j8Csmn/a2YerCXgG/5fM3NQF4qk7DULJDlIn24eHAmtAyuYqCghHlf4bUb X-Received: by 2002:aa7:da48:: with SMTP id w8mr2106885eds.81.1616055680458; Thu, 18 Mar 2021 01:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616055680; cv=none; d=google.com; s=arc-20160816; b=jnWaRmrnbQnnBHySajFUcRL0t6BWMo0Uh0Sh91aMfXm1aCkJylJSAGPNFc72CqXnsC beSQ+IH3QU2YNyEWD6ppBBKSNw5O+TwfYqBqSu7AnBgcdStReL2gwv2sT3x8SgSO9oD7 GlRlbyka6lk6P2lUR+IDP0MmGOC2jvrh/IBBUMIBSs8kgaBL89IssOahmCB/qXmtyYIu ml8TJfw5DJT6tWzBj8SD8+prYmqQ+EPElavsqkp/HT+vaPeiGkrmT3pPv1yzqBTSOCrf t4xTMcr5o+iT2rMnuLWb33HhA0DqyX0AVZ1uTg3a8ylfV4USbt0pN+uJP9t52Tbcx4+S bHZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RvYNB6RQjCIU1fWkQ6knkESI9o2/j+ICQI4BQBSyH7U=; b=QhfQDfFGG4k+iUV8fDFmwcOPbfoyg2QLLH/xCnyyorDuoCCApArnxVqy2QVS1J0m2y yGQ2Yq7jv1JlrLBfyBOrsXlJe7jWOQgW/FwwwnDlCPwgYKcX7jIp8qgSCariiuHcJQHq XFa1oYgnArEVrb51t7cz2LNUT/VwXQdvgkKHzPDkzdxkItKGcUdF9iY4fsVNrl5rzodZ i9MKi/iDihUj6BKcCr6sab+wziSOak1YwvhY3XzTkuIPBDdD6vFKML+/GhOHgcTAzOm+ iZsFGuS/AuhGtr+9jdyn4uob2W+1W6gdUJJVD05dk35n8ewY4vM976QMCBCA5BW9Ju21 /4EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=toPoZYi7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bq23si1093649ejb.498.2021.03.18.01.20.57; Thu, 18 Mar 2021 01:21:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=toPoZYi7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229638AbhCRISY (ORCPT + 99 others); Thu, 18 Mar 2021 04:18:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:49356 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbhCRISR (ORCPT ); Thu, 18 Mar 2021 04:18:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7D6C264EF6; Thu, 18 Mar 2021 08:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1616055497; bh=3E9H2zpeiDX6zhLzzRcdnJAvRLq5r0LmDVSbVqSH5PY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=toPoZYi70tiuUwSJYqo92mplFfSeGWj2ik1yhufFzen5C/HeF0MbGYzDQYB46llDj 4LCHbAPmBGvIeD6di0GoC+M5803q0r4t7a7AE4k06k3wJYsPf12qD0V3/NrP0ohEZm eJB7ZjL4cshxkdRAVtC3mAxMcouDKNP+n9nw1TSU3iTHu6Jx0ODcDbE74ihKmGvwyU ahbCDNPeQopboh+9SPM75PGBUTCqAPHat9pW3Q1ZooeY/I/nPHkOs4v5EPkWdOIm8V H9L4QuAASoDvtS7+nghvIORXU5tfBT0k/6VE5/7x3T0i/n8IsFmbQkAh/kkDeqLgxU qzRWQ90DG0mKA== Date: Thu, 18 Mar 2021 10:18:13 +0200 From: Leon Romanovsky To: Jiapeng Chong Cc: mst@redhat.com, jasowang@redhat.com, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, kpsingh@kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH] virtio_net: replace if (cond) BUG() with BUG_ON() Message-ID: References: <1615960635-29735-1-git-send-email-jiapeng.chong@linux.alibaba.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1615960635-29735-1-git-send-email-jiapeng.chong@linux.alibaba.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 17, 2021 at 01:57:15PM +0800, Jiapeng Chong wrote: > Fix the following coccicheck warnings: > > ./drivers/net/virtio_net.c:1551:2-5: WARNING: Use BUG_ON instead of if > condition followed by BUG. > > Reported-by: Abaci Robot > Signed-off-by: Jiapeng Chong > --- > drivers/net/virtio_net.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c > index 82e520d..093530b 100644 > --- a/drivers/net/virtio_net.c > +++ b/drivers/net/virtio_net.c > @@ -1545,10 +1545,8 @@ static int xmit_skb(struct send_queue *sq, struct sk_buff *skb) > else > hdr = skb_vnet_hdr(skb); > > - if (virtio_net_hdr_from_skb(skb, &hdr->hdr, > - virtio_is_little_endian(vi->vdev), false, > - 0)) > - BUG(); > + BUG_ON(virtio_net_hdr_from_skb(skb, &hdr->hdr, virtio_is_little_endian(vi->vdev), > + false, 0)); This BUG() in virtio isn't supposed to be in the first place. You should return -EINVAL instead of crashing system. Thanks > > if (vi->mergeable_rx_bufs) > hdr->num_buffers = 0; > -- > 1.8.3.1 >