From 60184823579de2062f4078c66f5d02c6450f8f83 Mon Sep 17 00:00:00 2001 From: Sebastian Doell Date: Thu, 21 Mar 2024 14:05:25 +0100 Subject: [PATCH] [NXDRVLINUX-150] - Fix "virteth" device allocation error, which led to an access violation at shutdown. --- libcifx/netx_tap/netx_tap.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/libcifx/netx_tap/netx_tap.c b/libcifx/netx_tap/netx_tap.c index 023551c..43283b9 100644 --- a/libcifx/netx_tap/netx_tap.c +++ b/libcifx/netx_tap/netx_tap.c @@ -264,19 +264,10 @@ void* cifxeth_create_device(NETX_ETH_DEV_CFG_T* config) /* Device successfully created */ OS_EnterLock( g_eth_list_lock); - if ((internal_dev = OS_Memalloc( sizeof(internal_dev))) != NULL) - { - TAILQ_INSERT_TAIL( &s_DeviceList, internal_dev, lentry); - ret = internal_dev; - } + TAILQ_INSERT_TAIL( &s_DeviceList, internal_dev, lentry); + ret = internal_dev; OS_LeaveLock( g_eth_list_lock); - if(NULL == ret) - { - if(g_ulTraceLevel & TRACE_LEVEL_ERROR) - { - USER_Trace( internal_dev->devinst, TRACE_LEVEL_ERROR, "Ethernet-IF Error: Not enough memory to create cifx virtual ethernet interface!"); - } - } + return ret; } } } @@ -289,6 +280,12 @@ void* cifxeth_create_device(NETX_ETH_DEV_CFG_T* config) { cifxeth_delete_device( internal_dev); } + } else + { + if(g_ulTraceLevel & TRACE_LEVEL_ERROR) + { + USER_Trace( internal_dev->devinst, TRACE_LEVEL_ERROR, "Ethernet-IF Error: Not enough memory to create cifx virtual ethernet interface!"); + } } channel_no++; }