]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sandbox: eth-raw: do not close the console input
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 27 Oct 2020 19:29:21 +0000 (20:29 +0100)
committerSimon Glass <sjg@chromium.org>
Thu, 5 Nov 2020 16:11:30 +0000 (09:11 -0700)
When the sandbox eth-raw device host_lo is removed this leads to closing
the console input.

Do not call close(0).

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sandbox/cpu/eth-raw-os.c
arch/sandbox/cpu/os.c

index da01d1addf9c2af3026589e41d78b10e08fad621..6a8d8097562bf0d87337361a37306f93c41a3d03 100644 (file)
@@ -53,7 +53,7 @@ int sandbox_eth_raw_os_is_local(const char *ifname)
        }
        ret = !!(ifr.ifr_flags & IFF_LOOPBACK);
 out:
-       close(fd);
+       os_close(fd);
        return ret;
 }
 
@@ -220,7 +220,7 @@ int sandbox_eth_raw_os_send(void *packet, int length,
                struct sockaddr_in addr;
 
                if (priv->local_bind_sd != -1)
-                       close(priv->local_bind_sd);
+                       os_close(priv->local_bind_sd);
 
                /* A normal UDP socket is required to bind */
                priv->local_bind_sd = socket(AF_INET, SOCK_DGRAM, 0);
@@ -284,11 +284,11 @@ void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv)
 {
        free(priv->device);
        priv->device = NULL;
-       close(priv->sd);
+       os_close(priv->sd);
        priv->sd = -1;
        if (priv->local) {
                if (priv->local_bind_sd != -1)
-                       close(priv->local_bind_sd);
+                       os_close(priv->local_bind_sd);
                priv->local_bind_sd = -1;
                priv->local_bind_udp_port = 0;
        }
index e7ec892bdf0714dd9a56db4ff730d8ce971ec592..c461fb0db0ed9d0c8a164987c188b36d6940248b 100644 (file)
@@ -86,7 +86,10 @@ int os_open(const char *pathname, int os_flags)
 
 int os_close(int fd)
 {
-       return close(fd);
+       /* Do not close the console input */
+       if (fd)
+               return close(fd);
+       return -1;
 }
 
 int os_unlink(const char *pathname)