From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id C13A51B1F4 for ; Mon, 10 Dec 2018 17:41:38 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Dec 2018 08:41:37 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,339,1539673200"; d="scan'208";a="99561671" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.237.220.93]) ([10.237.220.93]) by orsmga006.jf.intel.com with ESMTP; 10 Dec 2018 08:41:36 -0800 To: gfree.wind@vip.163.com, dev@dpdk.org Cc: Gao Feng References: <1543990764-32140-1-git-send-email-gfree.wind@vip.163.com> From: "Burakov, Anatoly" Message-ID: <23a41184-d366-ca83-4815-143ac350735e@intel.com> Date: Mon, 10 Dec 2018 16:41:35 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.2 MIME-Version: 1.0 In-Reply-To: <1543990764-32140-1-git-send-email-gfree.wind@vip.163.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [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: , X-List-Received-Date: Mon, 10 Dec 2018 16:41:39 -0000 On 05-Dec-18 6:19 AM, gfree.wind@vip.163.com wrote: > 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 > --- > 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"); The error should probably be more descriptive (as in, it should be easier to identify where it came from). Suggested rewording: "hotplug: cannot allocate memory for bundle" or something along those lines. Same for other log messages. As for actual code, Acked-by: Anatoly Burakov > + 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 > -- Thanks, Anatoly