Skip to contentSkip to conversation

virtio_net: drop redundant err assignment in virtnet_probe()

PATCH In review Li Wang 2 participants 2 messages May 20 – May 25

Subsystems (4)
lore
Share & tools
lore

Li Wang

author
#0 lore raw

PATCH 1/1 virtio_net: drop redundant err assignment in virtnet_probe()

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.

---
 drivers/net/virtio_net.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/virtio_net.c +1 -3
index f4adcfee7a80..1fbafca90e4c 100644
@@ -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));
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 3 lines · 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.