diff options
| author | Simon Glass <sjg@chromium.org> | 2018-11-15 18:44:06 -0700 |
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2018-11-26 08:25:37 -0500 |
| commit | fc1f58a4da74a8c123241f42a87200d59ee08e81 (patch) | |
| tree | d73157df72c6ba0dde7a4ba44cb712a7096d57d3 /arch/sandbox/cpu/eth-raw-os.c | |
| parent | 7b5ea1452742be72a28f52f4602c986eb342779b (diff) | |
sandbox: Use malloc() and free() from os layer
At present sandbox calls malloc() from various places in the OS layer and
this results in calls to U-Boot's malloc() implementation. It is better to
use the on in the OS layer, since it does not mix allocations with the
main U-Boot code.
Fix this by replacing calls with malloc() to os_malloc(), etc.
Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'arch/sandbox/cpu/eth-raw-os.c')
| -rw-r--r-- | arch/sandbox/cpu/eth-raw-os.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/arch/sandbox/cpu/eth-raw-os.c b/arch/sandbox/cpu/eth-raw-os.c index 75bfaa4c90a..8d05bc2eda0 100644 --- a/arch/sandbox/cpu/eth-raw-os.c +++ b/arch/sandbox/cpu/eth-raw-os.c @@ -11,6 +11,7 @@ #include <netinet/in.h> #include <netinet/ip.h> #include <netinet/udp.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -23,6 +24,8 @@ #include <linux/if_ether.h> #include <linux/if_packet.h> +#include <os.h> + struct sandbox_eth_raw_if_nameindex *sandbox_eth_raw_if_nameindex(void) { return (struct sandbox_eth_raw_if_nameindex *)if_nameindex(); @@ -71,7 +74,7 @@ static int _raw_packet_start(struct eth_sandbox_raw_priv *priv, /* Prepare device struct */ priv->local_bind_sd = -1; - priv->device = malloc(sizeof(struct sockaddr_ll)); + priv->device = os_malloc(sizeof(struct sockaddr_ll)); if (priv->device == NULL) return -ENOMEM; device = priv->device; @@ -144,7 +147,7 @@ static int _local_inet_start(struct eth_sandbox_raw_priv *priv) /* Prepare device struct */ priv->local_bind_sd = -1; priv->local_bind_udp_port = 0; - priv->device = malloc(sizeof(struct sockaddr_in)); + priv->device = os_malloc(sizeof(struct sockaddr_in)); if (priv->device == NULL) return -ENOMEM; device = priv->device; @@ -279,7 +282,7 @@ int sandbox_eth_raw_os_recv(void *packet, int *length, void sandbox_eth_raw_os_stop(struct eth_sandbox_raw_priv *priv) { - free(priv->device); + os_free(priv->device); priv->device = NULL; close(priv->sd); priv->sd = -1; |
