This patch fixes memory leak in parsing error handling.
Fixes:
338327d731e6 ("devargs: add function to parse device layers")
Cc: stable@dpdk.org
Signed-off-by: Xueming Li <xuemingl@nvidia.com>
Reviewed-by: Gaetan Rivet <grive@u256.net>
size_t nblayer;
size_t i = 0;
int ret = 0;
+ bool allocated_data = false;
/* Split each sub-lists. */
nblayer = devargs_layer_count(devstr);
ret = -ENOMEM;
goto get_out;
}
+ allocated_data = true;
s = devargs->data;
}
if (layers[i].kvlist)
rte_kvargs_free(layers[i].kvlist);
}
- if (ret != 0)
+ if (ret != 0) {
+ if (allocated_data) {
+ /* Free duplicated data. */
+ free(devargs->data);
+ devargs->data = NULL;
+ }
rte_errno = -ret;
+ }
return ret;
}