Netdev List
 help / color / mirror / Atom feed
* [PATCH] virtio_net: drop redundant err assignment in virtnet_probe()
@ 2026-05-20 10:23 Li Wang
  2026-05-25 18:49 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Li Wang @ 2026-05-20 10:23 UTC (permalink / raw)
  To: Michael S . Tsirkin, Jason Wang
  Cc: Xuan Zhuo, Eugenio Pérez, netdev, virtualization,
	linux-kernel, Li Wang

err is initialized to -ENOMEM at the start of virtnet_probe(), and no
code path between that and the devm_kzalloc() failure can change
err. Assigning -ENOMEM again before goto free therefore is redundant.

Signed-off-by: Li Wang <liwang@kylinos.cn>
---
 drivers/net/virtio_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index f4adcfee7a80..1fbafca90e4c 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -6853,10 +6853,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 				rss_max_indirection_table_length));
 	}
 	vi->rss_hdr = devm_kzalloc(&vdev->dev, virtnet_rss_hdr_size(vi), GFP_KERNEL);
-	if (!vi->rss_hdr) {
-		err = -ENOMEM;
+	if (!vi->rss_hdr)
 		goto free;
-	}
 
 	if (vi->has_rss || vi->has_rss_hash_report) {
 		key_sz = virtio_cread8(vdev, offsetof(struct virtio_net_config, rss_max_key_size));
-- 
2.34.1


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

* Re: [PATCH] virtio_net: drop redundant err assignment in virtnet_probe()
  2026-05-20 10:23 [PATCH] virtio_net: drop redundant err assignment in virtnet_probe() Li Wang
@ 2026-05-25 18:49 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2026-05-25 18:49 UTC (permalink / raw)
  To: Li Wang
  Cc: Michael S . Tsirkin, Jason Wang, Xuan Zhuo, Eugenio Pérez,
	netdev, virtualization, linux-kernel

On Wed, 20 May 2026 18:23:09 +0800 Li Wang wrote:
> err is initialized to -ENOMEM at the start of virtnet_probe(), and no
> code path between that and the devm_kzalloc() failure can change
> err. Assigning -ENOMEM again before goto free therefore is redundant.

This is asking for a bug, someone may add code before this 
if () overriding err to 0. They are 130 lines apart!

If you want to removing something remove the inline init at the start
of the function. But FTR I think that'd also be pointless churn.

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

end of thread, other threads:[~2026-05-25 18:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 10:23 [PATCH] virtio_net: drop redundant err assignment in virtnet_probe() Li Wang
2026-05-25 18:49 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox