diff mbox series

[U-Boot,v3,04/11] sandbox: eth-raw: Make sure descriptors are always initialized

Message ID 20180702194754.1955-5-joe.hershberger@ni.com
State Accepted
Commit 50ed0ef
Delegated to: Joe Hershberger
Headers show
Series sandbox: net: Fix sandbox eth drivers | expand

Commit Message

Joe Hershberger July 2, 2018, 7:47 p.m. UTC
If we let descriptors equal 0, we can end up closing STDIN. Make sure
they start out as -1.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v3: None
Changes in v2: None

 arch/sandbox/cpu/eth-raw-os.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

Joe Hershberger July 26, 2018, 7:15 p.m. UTC | #1
Hi Joe,

https://patchwork.ozlabs.org/patch/938156/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c
index 61f23ed210..4263d8829a 100644
--- a/arch/sandbox/cpu/eth-raw-os.c
+++ b/arch/sandbox/cpu/eth-raw-os.c
@@ -34,6 +34,7 @@  static int _raw_packet_start(const char *ifname, unsigned char *ethmac,
 	int flags;
 
 	/* Prepare device struct */
+	priv->local_bind_sd = -1;
 	priv->device = malloc(sizeof(struct sockaddr_ll));
 	if (priv->device == NULL)
 		return -ENOMEM;
@@ -103,6 +104,8 @@  static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
 	int one = 1;
 
 	/* Prepare device struct */
+	priv->local_bind_sd = -1;
+	priv->local_bind_udp_port = 0;
 	priv->device = malloc(sizeof(struct sockaddr_in));
 	if (priv->device == NULL)
 		return -ENOMEM;
@@ -136,8 +139,6 @@  static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
 		       strerror(errno));
 		return -errno;
 	}
-	priv->local_bind_sd = -1;
-	priv->local_bind_udp_port = 0;
 	return 0;
 }