[PATCH v2] net/tap: Set return code on failure

Patrick Venture posted 1 patch 2 years, 2 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20220105164214.3381151-1-venture@google.com
Maintainers: Jason Wang <jasowang@redhat.com>
There is a newer version of this series
net/tap.c | 1 +
1 file changed, 1 insertion(+)
[PATCH v2] net/tap: Set return code on failure
Posted by Patrick Venture 2 years, 2 months ago
From: Peter Foley <pefoley@google.com>

Match the other error handling in this function.

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

Reviewed-by: Patrick Venture <venture@google.com>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Peter Foley <pefoley@google.com>
---
v2: Fixed commit titlewq and updated description.
---
 net/tap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/tap.c b/net/tap.c
index f716be3e3f..c5cbeaa7a2 100644
--- a/net/tap.c
+++ b/net/tap.c
@@ -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)) {
-- 
2.34.1.448.ga2b2bfdf31-goog


Re: [PATCH v2] net/tap: Set return code on failure
Posted by Stefano Garzarella 2 years, 2 months ago
On Wed, Jan 05, 2022 at 08:42:14AM -0800, Patrick Venture wrote:
>From: Peter Foley <pefoley@google.com>
>
>Match the other error handling in this function.
>
>Fixes: e7b347d0bf6 ("net: detect errors from probing vnet hdr flag for TAP devices")
>
>Reviewed-by: Patrick Venture <venture@google.com>
>Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>Signed-off-by: Peter Foley <pefoley@google.com>
>---
>v2: Fixed commit titlewq and updated description.
>---
> net/tap.c | 1 +
> 1 file changed, 1 insertion(+)
>
>diff --git a/net/tap.c b/net/tap.c
>index f716be3e3f..c5cbeaa7a2 100644
>--- a/net/tap.c
>+++ b/net/tap.c
>@@ -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:

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>