From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id E43955594; Fri, 9 Sep 2016 10:43:31 +0200 (CEST) Received: from [37.164.104.53] (helo=[192.168.42.87]) by mail.droids-corp.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1biHS8-00071K-C9; Fri, 09 Sep 2016 10:46:29 +0200 To: Yuanhan Liu References: <1473408985-13131-1-git-send-email-olivier.matz@6wind.com> <20160909082501.GW7328@yliu-dev.sh.intel.com> Cc: dev@dpdk.org, pablo.de.lara.guarch@intel.com, stable@dpdk.org From: Olivier Matz Message-ID: <0504b8cb-891c-99c7-dbc7-fd2ddd11423d@6wind.com> Date: Fri, 9 Sep 2016 10:43:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160909082501.GW7328@yliu-dev.sh.intel.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [dpdk-stable] [PATCH] testpmd: fix crash when mempool allocation fails X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Sep 2016 08:43:32 -0000 Hi Yuanhan, On 09/09/2016 10:25 AM, Yuanhan Liu wrote: > On Fri, Sep 09, 2016 at 10:16:25AM +0200, Olivier Matz wrote: >> Avoid access to mempool pointer if it is NULL. >> >> Fixes: b19a0c75a0d4 ("app/testpmd: remove anonymous mempool code") >> Coverity issue: 127553 >> >> Signed-off-by: Olivier Matz >> --- >> app/test-pmd/testpmd.c | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c >> index 1428974..e0f8285 100644 >> --- a/app/test-pmd/testpmd.c >> +++ b/app/test-pmd/testpmd.c >> @@ -444,10 +444,13 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, >> mb_size, (unsigned) mb_mempool_cache, >> sizeof(struct rte_pktmbuf_pool_private), >> socket_id, 0); >> + if (rte_mp == NULL) >> + goto err; >> >> if (rte_mempool_populate_anon(rte_mp) == 0) { >> rte_mempool_free(rte_mp); >> rte_mp = NULL; >> + goto err; >> } >> rte_pktmbuf_pool_init(rte_mp, NULL); >> rte_mempool_obj_iter(rte_mp, rte_pktmbuf_init, NULL); >> @@ -458,6 +461,7 @@ mbuf_pool_create(uint16_t mbuf_seg_size, unsigned nb_mbuf, >> } >> } >> >> + err: > > A minor nit: there is a heading white space char. > Well, that's something I've been doing since a long time due to my editor config, but I cannot find any good reason for doing that. I'll send a v2 without this space (and fix my config for next times ;)) Olivier