eal: fix leak on multi-process request error
authorGao Feng <davidfgao@tencent.com>
Wed, 5 Dec 2018 02:50:25 +0000 (10:50 +0800)
committerThomas Monjalon <thomas@monjalon.net>
Wed, 19 Dec 2018 23:01:28 +0000 (00:01 +0100)
When rte_eal_alarm_set failed, need to free the bundle mem in the
error handler of handle_primary_request and handle_secondary_request.

Fixes: 244d5130719c ("eal: enable hotplug on multi-process")
Fixes: ac9e4a17370f ("eal: support attach/detach shared device from secondary")
Cc: stable@dpdk.org
Signed-off-by: Gao Feng <davidfgao@tencent.com>
Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>
lib/librte_eal/common/hotplug_mp.c

index 070e2e0..9d610a8 100644 (file)
@@ -208,6 +208,8 @@ handle_secondary_request(const struct rte_mp_msg *msg, const void *peer)
        ret = rte_eal_alarm_set(1, __handle_secondary_request, bundle);
        if (ret != 0) {
                RTE_LOG(ERR, EAL, "failed to add mp task\n");
+               free(bundle->peer);
+               free(bundle);
                return send_response_to_secondary(req, ret, peer);
        }
        return 0;
@@ -332,6 +334,8 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer)
         */
        ret = rte_eal_alarm_set(1, __handle_primary_request, bundle);
        if (ret != 0) {
+               free(bundle->peer);
+               free(bundle);
                resp->result = ret;
                ret = rte_mp_reply(&mp_resp, peer);
                if  (ret != 0) {