virtio_net: drop redundant err assignment in virtnet_probe()
Subsystems (4)
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.
Signed-off-by Li Wang <[email protected]>
--- drivers/net/virtio_net.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/virtio_net.c +1 -3
@@ -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
Jakub Kicinski
maintainerQuoted 3 lines · On Wed, 20 May 2026 18:23:09 +0800 Li Wang wrote:
err is initialized to
-ENOMEMat the start ofvirtnet_probe(), and no code path between that and thedevm_kzalloc()failure can change err. Assigning-ENOMEMagain 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.