* [PATCH] virtio_net: replace if (cond) BUG() with BUG_ON()
@ 2021-03-17 5:57 Jiapeng Chong
2021-03-18 8:18 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-03-17 5:57 UTC (permalink / raw)
To: mst
Cc: jasowang, davem, kuba, ast, daniel, hawk, john.fastabend, andrii,
kafai, songliubraving, yhs, kpsingh, virtualization, netdev,
linux-kernel, bpf, Jiapeng Chong
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 <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
---
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));
if (vi->mergeable_rx_bufs)
hdr->num_buffers = 0;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] virtio_net: replace if (cond) BUG() with BUG_ON()
2021-03-17 5:57 [PATCH] virtio_net: replace if (cond) BUG() with BUG_ON() Jiapeng Chong
@ 2021-03-18 8:18 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2021-03-18 8:18 UTC (permalink / raw)
To: Jiapeng Chong
Cc: mst, jasowang, davem, kuba, ast, daniel, hawk, john.fastabend,
andrii, kafai, songliubraving, yhs, kpsingh, virtualization,
netdev, linux-kernel, bpf
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 <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> ---
> 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
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-18 8:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-17 5:57 [PATCH] virtio_net: replace if (cond) BUG() with BUG_ON() Jiapeng Chong
2021-03-18 8:18 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).