Skip to contentSkip to conversation

net/tap: Set return code on failure

PATCH In review Patrick Venture 2 participants 2 messages Jan 5, 2022 – Jan 10, 2022 Networking

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net/tap: Set return code on failure

From: Peter Foley <[email protected]>

Match the other error handling in this function.

Fixes e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")

---
v2: Fixed commit titlewq and updated description.

---
 net/tap.c | 1 +
 1 file changed, 1 insertion(+)
net/tap.c +1 -0
index f716be3e3f..c5cbeaa7a2 100644
@@ -900,6 +900,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
             if (i == 0) {
                 vnet_hdr = tap_probe_vnet_hdr(fd, errp);
                 if (vnet_hdr < 0) {
+                    ret = -1;
                     goto free_fail;
                 }
             } else if (vnet_hdr != tap_probe_vnet_hdr(fd, NULL)) {
Signature · 1 line
2.34.1.448.ga2b2bfdf31-goog
Reviewed-by on v2 1/1
#1 lore raw
Quoted 20 lines · Patrick Venture

From: Peter Foley <[email protected]>

Match the other error handling in this function.

Fixes e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")

---
v2: Fixed commit titlewq and updated description.
---
net/tap.c | 1 +

1 file changed, 1 insertion(+)
net/tap.c +0 -0
index f716be3e3f..c5cbeaa7a2 100644

net/tap.c int net_init_tap(const Netdev *netdev, const char *name, · line 903

Quoted 4 lines
net/tap.c +1 -0
@@ -900,6 +900,7 @@ int net_init_tap(const Netdev *netdev, const char *name,
            if (i == 0) {
                vnet_hdr = tap_probe_vnet_hdr(fd, errp);
                if (vnet_hdr < 0) {
+                    ret = -1;

In case of error, vnet_hdr should contain an error code (negative), so we could assign ret = vnet_hdr, but looking at the implementation of tap_probe_vnet_hdr(), in case of error it returns just -1, so it's ok too: