hostapd/wlantest
Gokul Sivakumar 30cf0d107f wlantest: Properly free allocated memory on error exit paths
In the cases when a failure is experienced, the value "-1" was returned
from the main() function without doing any cleanup or deinit.

For example, if wlantest was started with the following set of command
line arguments then later when returning after a failure from main()
function, the memory allocated as part of handling the "-p" getopt
command line option was not freed. To fix memory leaks in this case,
properly free the previously allocated memory with the help of
wlantest_deinit() before returning from main().

$ sudo valgrind --leak-check=full --show-leak-kinds=all --verbose \
> --track-origins=yes --log-file=valgrind-out.txt \
> ./wlantest -i hwsim0 -dd -c -p "asdfasdfasdfasdf" -W "abcd"
Invalid WEP key 'abcd'

Memory leak reported by Valgrind when running wlantest as mentioned above.

==513454== HEAP SUMMARY:
==513454==     in use at exit: 128 bytes in 1 blocks
==513454==   total heap usage: 4 allocs, 3 frees, 5,720 bytes allocated
==513454==
==513454== Searching for pointers to 1 not-freed blocks
==513454== Checked 76,936 bytes
==513454==
==513454== 128 bytes in 1 blocks are definitely lost in loss record 1 of 1
==513454==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==513454==    by 0x1396CA: os_zalloc (in /home/ubuntu/hostap/wlantest/wlantest)
==513454==    by 0x10C345: add_passphrase (wlantest.c:125)
==513454==    by 0x10C345: main (wlantest.c:425)
==513454==
==513454== LEAK SUMMARY:
==513454==    definitely lost: 128 bytes in 1 blocks
==513454==    indirectly lost: 0 bytes in 0 blocks
==513454==      possibly lost: 0 bytes in 0 blocks
==513454==    still reachable: 0 bytes in 0 blocks
==513454==         suppressed: 0 bytes in 0 blocks
==513454==
==513454== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)

Signed-off-by: Gokul Sivakumar <gokulkumar792@gmail.com>
2021-12-11 21:37:06 +02:00
..
.gitignore gitignore: Clean up a bit 2020-10-11 19:32:50 +03:00
bip.c wlantest: Fix bip_protect() memory allocation 2016-03-14 18:42:46 +02:00
bss.c wlantest: Fix PMK length and passphrase-based key derivation for FT 2021-10-14 16:28:02 +03:00
ccmp.c Rename the Frame Control field subfield Order define to +HTC 2021-05-06 12:12:51 +03:00
ctrl.c OCV: Add wlantest support for indicating OCV 2018-12-17 00:02:14 +02:00
gcmp.c Rename the Frame Control field subfield Order define to +HTC 2021-05-06 12:12:51 +03:00
inject.c Replace "dummy" with "stub" in wlantest injection 2021-10-11 20:53:11 +03:00
Makefile wlantest: Include PASN into build 2021-01-25 18:35:50 +02:00
monitor.c wlantest: Comment out Linux packet socket from OS X build 2020-04-05 18:53:59 +03:00
process.c wlantest: Ethernet interface capture 2019-12-27 23:16:45 +02:00
readpcap.c wlantest: Detect and report plaintext payload in protected frames 2020-03-14 17:36:41 +02:00
rx_data.c wlantest: TKIP frame reassembly for Michael MIC check in fragmented case 2021-05-11 21:13:56 +03:00
rx_eapol.c wlantest: Fix PMK length and passphrase-based key derivation for FT 2021-10-14 16:28:02 +03:00
rx_ip.c wlantest: Avoid unaligned iphdr pointers 2021-02-13 23:07:34 +02:00
rx_mgmt.c wlantest: Add more details about protected FTM frames 2021-02-07 13:11:34 +02:00
rx_tdls.c Simplify Timeout Interval element parsing 2015-04-22 22:05:11 +03:00
sta.c wlantest: Add new key_mgmt and rsn_capab values for BSS/STA debug prints 2021-02-07 13:57:03 +02:00
test_vectors.c wlantest: TKIP frame reassembly for Michael MIC check in fragmented case 2021-05-11 21:13:56 +03:00
tkip.c wlantest: TKIP frame reassembly for Michael MIC check in fragmented case 2021-05-11 21:13:56 +03:00
wep.c Move CRC-32 routine from wlantest to src/utils 2016-10-09 17:13:23 +03:00
wired.c wlantest: Use BSD compatible UDP header struct 2020-04-05 18:53:59 +03:00
wlantest.c wlantest: Properly free allocated memory on error exit paths 2021-12-11 21:37:06 +02:00
wlantest.h wlantest: TKIP frame reassembly for Michael MIC check in fragmented case 2021-05-11 21:13:56 +03:00
wlantest_cli.c wlantest: Add a BSS probe_response counter 2013-12-26 13:37:06 +02:00
wlantest_ctrl.h wlantest: Add a BSS probe_response counter 2013-12-26 13:37:06 +02:00
writepcap.c wlantest: Ethernet interface capture 2019-12-27 23:16:45 +02:00