in show_gtp_cmd, we have two different checks (argc > 0) vs (argc)
which means in theory argc could be negative and the second clause
would be executed without the first having set up related data such as
'ai'.
Fixes: CID#307521: Explicit null dereferenced (FORWARD_NULL)
Change-Id: I4149b0b191a34168ba6649338d3cdf6c6af6cfe7
The main thread calls pthread_cancel before freeing the tun object.
However, pthread_cancel doesn't kill the thread synchronously (man
pthread_cancel). Hence, the tun thread may still be running for a while
after the tun object is/has been(ing) freed.
Let's avoid this by making sure the thread is stopped before
freeing the object.
To accomplish it, we must wait for the thread to be cancelled. A cleanup
routie is added which will signal the "tun_released" message to the main
thread through an osmo_itq, which will then free the object (since
talloc context is managed by the main thread).
Related: SYS#5523
Change-Id: Idf005359afb41d3413b09281a9ff937d5eafcc7c