From: Gao Feng Date: Wed, 5 Dec 2018 06:19:24 +0000 (+0800) Subject: eal: check peer allocation in multi-process request X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=32fa7f8913930be9bb44995e391b5c6b2a88efb6;p=dpdk.git eal: check peer allocation in multi-process request Add the check for null peer pointer like the bundle pointer in the mp request handler. They should follow same style. And add some logs for nomem cases. Signed-off-by: Gao Feng Acked-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 9d610a8a20..4052a5c7fb 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -200,6 +200,11 @@ handle_secondary_request(const struct rte_mp_msg *msg, const void *peer) * when it is ready. */ bundle->peer = strdup(peer); + if (bundle->peer == NULL) { + free(bundle); + RTE_LOG(ERR, EAL, "not enough memory\n"); + return send_response_to_secondary(req, -ENOMEM, peer); + } /** * We are at IPC callback thread, sync IPC is not allowed due to @@ -313,6 +318,7 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer) bundle = calloc(1, sizeof(*bundle)); if (bundle == NULL) { + RTE_LOG(ERR, EAL, "not enough memory\n"); resp->result = -ENOMEM; ret = rte_mp_reply(&mp_resp, peer); if (ret) @@ -327,6 +333,15 @@ handle_primary_request(const struct rte_mp_msg *msg, const void *peer) * when it is ready. */ bundle->peer = (void *)strdup(peer); + if (bundle->peer == NULL) { + RTE_LOG(ERR, EAL, "not enough memory\n"); + free(bundle); + resp->result = -ENOMEM; + ret = rte_mp_reply(&mp_resp, peer); + if (ret) + RTE_LOG(ERR, EAL, "failed to send reply to primary request\n"); + return ret; + } /** * We are at IPC callback thread, sync IPC is not allowed due to