mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-07 15:01:59 +00:00
sandbox: eth-raw: Make sure descriptors are always initialized
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>
This commit is contained in:
parent
68acb51f44
commit
50ed0ef832
1 changed files with 3 additions and 2 deletions
|
@ -34,6 +34,7 @@ static int _raw_packet_start(const char *ifname, unsigned char *ethmac,
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
/* Prepare device struct */
|
/* Prepare device struct */
|
||||||
|
priv->local_bind_sd = -1;
|
||||||
priv->device = malloc(sizeof(struct sockaddr_ll));
|
priv->device = malloc(sizeof(struct sockaddr_ll));
|
||||||
if (priv->device == NULL)
|
if (priv->device == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -103,6 +104,8 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
|
||||||
int one = 1;
|
int one = 1;
|
||||||
|
|
||||||
/* Prepare device struct */
|
/* Prepare device struct */
|
||||||
|
priv->local_bind_sd = -1;
|
||||||
|
priv->local_bind_udp_port = 0;
|
||||||
priv->device = malloc(sizeof(struct sockaddr_in));
|
priv->device = malloc(sizeof(struct sockaddr_in));
|
||||||
if (priv->device == NULL)
|
if (priv->device == NULL)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
@ -136,8 +139,6 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return -errno;
|
return -errno;
|
||||||
}
|
}
|
||||||
priv->local_bind_sd = -1;
|
|
||||||
priv->local_bind_udp_port = 0;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue