From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f47.google.com (mail-wm0-f47.google.com [74.125.82.47]) by dpdk.org (Postfix) with ESMTP id B86E05688 for ; Mon, 2 May 2016 12:34:20 +0200 (CEST) Received: by mail-wm0-f47.google.com with SMTP id g17so135183522wme.1 for ; Mon, 02 May 2016 03:34:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:organization:user-agent :in-reply-to:references:mime-version:content-transfer-encoding; bh=GiAlxBtXovAnXcl54gte3L/IGis/zBSF68Z9Hrx9pEY=; b=HVaG9UcIJ4PpAnF1yYk6UtOqotpG8BuRXcpLE7LwZpI6OoKxgYRqmuSNeS39Ypu98u qWT1kKx0u2G0AYAJbchC7TPBtwf9KUtPMGjj+CwvUT+fHYbGEijAfDTGCJpqPhd2BNN+ jZhxyOgKSzryi5ua8w+cJuV1/c6IhJYCK4syoq2dSpEom/Sks1q6Ys1t2JtvyFqr5cSC 99Jb0c7gzy3dfZ8TXIiyp5zfh65N0HyxcEiLcyMrtBY8+ZmjdN9yUKBp0b+wheFvCXOy kSYn/sPwztVnmn7MBuGHgmUPlI80tqkoOiy3vQTBf7xy4zsqRSzRcKKD8TMqz6XJ1uBT KrdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding; bh=GiAlxBtXovAnXcl54gte3L/IGis/zBSF68Z9Hrx9pEY=; b=X3FGxHxkqaF5XK9QrPwrCHHjY2H2bu/Nf/rIaXNvNtHcVcZ4pjyQWhFn4egK2Dk0K5 T4/sAWPTHh5rtW2a7FLRPeRwYKNcsZ/XrDIcyVO2ieO6j9Z1fkE5fb1al88/3KUKmnU0 6dU5tQp8dKL/kth6X96ILxAQBMcXCaZykqAK/MLK23KC/bq4fhpDilxgNzMGb4ftZN9x Jh6GHkLxao4RyBGe3sprHS2XijWLScxsbRUL84hM3DC0dG6jN5xwCswmIQvitayoggLz mjwuA0GUXG1hci8IvBYdCSvbS65btRbsg2MXD1JP1PJr6TSM1WTNymgJDHhDxVsKuGNb wPZA== X-Gm-Message-State: AOPr4FVs7pFn+uYTWxZwYgQGMAmJLlTWhTU1GeEJwJJNlK39AvfMn3jPthV4BhwCtPdMJgkY X-Received: by 10.28.29.195 with SMTP id d186mr19438659wmd.27.1462185260488; Mon, 02 May 2016 03:34:20 -0700 (PDT) Received: from xps13.localnet (207.111.75.86.rev.sfr.net. [86.75.111.207]) by smtp.gmail.com with ESMTPSA id f11sm18142987wmf.22.2016.05.02.03.34.19 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 02 May 2016 03:34:19 -0700 (PDT) From: Thomas Monjalon To: Christian Ehrhardt Cc: dev@dpdk.org, Olivier MATZ , bruce.richardson@intel.com Date: Mon, 02 May 2016 12:34:18 +0200 Message-ID: <2715506.Wi630GEmLA@xps13> Organization: 6WIND User-Agent: KMail/4.14.10 (Linux/4.1.6-1-ARCH; KDE/4.14.11; x86_64; ; ) In-Reply-To: <570D0EFC.2060107@6wind.com> References: <1460468967-9206-1-git-send-email-christian.ehrhardt@canonical.com> <570D0EFC.2060107@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Subject: Re: [dpdk-dev] [PATCH] lpm: fix freeing of rules_tbl in rte_lpm_free_v20 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: Mon, 02 May 2016 10:34:20 -0000 > > Back then when we fixed the missing free lpm I was to quickly to say yes > > if it applies not only to the lpm6 but also to all of the lpm code. > > > > It turned out to not apply to all of them. In rte_lpm_create_v20 there > > is an unexpected fused allocation: > > mem_size = sizeof(*lpm) + (sizeof(lpm->rules_tbl[0]) * max_rules); > > [...] > > lpm = (struct rte_lpm_v20 *)rte_zmalloc_socket(mem_name,mem_size, > > RTE_CACHE_LINE_SIZE, socket_id); > > > > That causes lpm->rules_tbl not to have an own struct malloc_elem that > > can be derived via RTE_PTR_SUB(data, MALLOC_ELEM_HEADER_LEN) in > > malloc_elem_from_data. > > Due to that the rte_lpm_free_v20 accidentially misderives the elem and > > assumes it is ELEM_FREE triggering in malloc_elem_free > > if (!malloc_elem_cookies_ok(elem) || elem->state != > > return -1; > > > > While it seems counter-intuitive the way to properly remove rules_tbl in > > the old fused allocation style of rte_lpm_free_v20 is to not remove it. > > > > The newer rte_lpm_free_v1604 is safe because in rte_lpm_create_v1604 > > rules_tbl is a separate allocation. > > > > Fixes: d4c18f0a1d5d ("lpm: fix missing free") > > > > Signed-off-by: Christian Ehrhardt > > Acked-by: Olivier Matz > > Thanks, I missed it too during the review. Applied, thanks