From patchwork Wed Dec 5 06:19:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gao Feng X-Patchwork-Id: 48529 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 242BC1B130; Wed, 5 Dec 2018 07:19:45 +0100 (CET) Received: from m181-177.vip.163.com (m181-177.vip.163.com [123.58.177.181]) by dpdk.org (Postfix) with ESMTP id B2E5F1B122 for ; Wed, 5 Dec 2018 07:19:42 +0100 (CET) Received: from localhost.localdomain (unknown [116.196.72.250]) by smtp2 (Coremail) with SMTP id oWZ4CgDHbXrtbQdcRUawAw--.9701S2; Wed, 05 Dec 2018 14:19:40 +0800 (CST) From: gfree.wind@vip.163.com To: dev@dpdk.org Cc: Gao Feng Date: Wed, 5 Dec 2018 14:19:24 +0800 Message-Id: <1543990764-32140-1-git-send-email-gfree.wind@vip.163.com> X-Mailer: git-send-email 2.7.4 X-CM-TRANSID: oWZ4CgDHbXrtbQdcRUawAw--.9701S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7CF4DZF1DCw4DCFWUWFWrGrg_yoW8WFWrpr Z3GF15tr4UJr1xZ34fZ3sY9ryrAFZ3Jws7ZFWrCa47uws3X39xA3yFkFyY9r13CrykXa4v yr4rZFy7Kr1kJaUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jbF4iUUUUU= X-Originating-IP: [116.196.72.250] X-CM-SenderInfo: 5jiuvvgozl0vg6yl1hqrwthudrp/1tbiHRwUs1Qj30+VOQAAst Subject: [dpdk-dev] [PATCH] eal: Add the check for null peer pointer in mp request handler X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Gao Feng 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 --- lib/librte_eal/common/hotplug_mp.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/librte_eal/common/hotplug_mp.c b/lib/librte_eal/common/hotplug_mp.c index 070e2e0..0d2996f 100644 --- a/lib/librte_eal/common/hotplug_mp.c +++ b/lib/librte_eal/common/hotplug_mp.c @@ -200,6 +200,11 @@ static int cmp_dev_name(const struct rte_device *dev, const void *_name) * 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 @@ -311,6 +316,7 @@ static void __handle_primary_request(void *param) 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) @@ -325,6 +331,15 @@ static void __handle_primary_request(void *param) * 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