eal: fix memory leak on control thread failure
authorJianfeng Tan <jianfeng.tan@intel.com>
Wed, 2 May 2018 10:26:32 +0000 (10:26 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 2 May 2018 15:15:02 +0000 (17:15 +0200)
params is not freed if pthread_create() fails. The fix is
straight-forward.

Fixes: 3d09a6e26d8b ("eal: fix threads block on barrier")

Reported-by: Olivier Matz <olivier.matz@6wind.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
lib/librte_eal/common/eal_common_thread.c

index de69452..a2c05e4 100644 (file)
@@ -178,8 +178,10 @@ rte_ctrl_thread_create(pthread_t *thread, const char *name,
        pthread_barrier_init(&params->configured, NULL, 2);
 
        ret = pthread_create(thread, attr, rte_thread_init, (void *)params);
-       if (ret != 0)
+       if (ret != 0) {
+               free(params);
                return ret;
+       }
 
        if (name != NULL) {
                ret = rte_thread_setname(*thread, name);