Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp180829ybj; Wed, 6 May 2020 14:38:39 -0700 (PDT) X-Google-Smtp-Source: APiQypKcGsi11Uj/Hlck7Jru+4CqJNyj1XsDTL9kbi6h8Vpm/09b483AzX1aOeAicu8ZoVXE+2pv X-Received: by 2002:a17:907:2098:: with SMTP id pv24mr9572516ejb.22.1588801119788; Wed, 06 May 2020 14:38:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588801119; cv=none; d=google.com; s=arc-20160816; b=QSYX2RnmYSpvVXWw8+snfm0Txs2u93t91lmWO4t52JRAvTCSm20vV9UqFl/4lkTSV6 GH5mvk2KNIj3ifDfv9Wb7Ui/vLi03gq8rLKR8+ZqVt7oQ/vUlxpwgPgLC0Hnntijyelh YV91N2DpBtCv9qyNhDDUvstP80sh6TfVlq52E+y5F7Of3QfHlESaWv35VbaoO+ZS0OL5 gxJ90/FgPQtqa6c/iA4C9s1VyZv5Vi4OlVJhtU5bxSA2EwibkAVnWGgOArNnwQBp35mo qNMrF671NKOlfsfEE1IczpyGs4q4kweHUMmg/ywrd/Oa7SFz7VA8o1NVyAWZakvJdUk/ 1ejQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=sLuNCU2JM/epZOTJGI+BJEI5qSqulxTn0n+nKtPntxY=; b=0sdOANKQjhVFLmBu3TYUEvgTblnhOoxr4J+UGfcSlhvduoYG7ANHM5VLY7HbKdr+ss 7+q9R2+ZC84q4yTrZLmr341ogV+BSFf2POemvnTg9pxoUTmZgI6Fr+BtF6/GooASf9i1 bbp5rat2iXkfUM+C1g9H1JPiB5twsNgvH3CpYyGn8FZ/toThqfBn/X3HvmZph7IvI8YC 5K9r7lWMc69HMWZogZzuVG70w75AoOe3p0jIcM0vJj+0A8VPPqV+7HPXB0ZzZB784iIV KqKjixWzHseANb1SFjEauE5C7cADR6GrbexRmPgXtnS4SFI1PTVbLYBH1FcHXDxiN25l +8VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQak3jbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l17si1883739edw.425.2020.05.06.14.38.16; Wed, 06 May 2020 14:38:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sQak3jbP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729787AbgEFVgg (ORCPT + 99 others); Wed, 6 May 2020 17:36:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729391AbgEFVgf (ORCPT ); Wed, 6 May 2020 17:36:35 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8CDC061A0F; Wed, 6 May 2020 14:36:35 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id o16so2535051qtb.13; Wed, 06 May 2020 14:36:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=sLuNCU2JM/epZOTJGI+BJEI5qSqulxTn0n+nKtPntxY=; b=sQak3jbP3LldPznsXSiqinAFTq/1BN0yY6SzjCKuEsVT1MyrGLHPxcgCs6t9TH2Mgg jSlb9WYTP1Bn5tG7b4PdUvo0Wc/rywdiT4C5700AeCFMQDEqXvt3uBjMa7UdWKDrYZ1h ODAMrTb11R5oX/qtRcuBoZaKfkgRAScdSR11lRmQmIYOf3GdpvhQVJ/D8cxSmAaMmC3f 34F5Fp0wp/hlJailM8yiVav93Ce4YWgrUzDX6uOK1jglli3PFHn1E2Xxd5o+qAlAcwTk vrDHuKKMP/j1MBr2A8WOXHAzuf8vv1AJzsaGM96Wbprudd38vk1mNKMn6gI4foICxv7s O9Vg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sLuNCU2JM/epZOTJGI+BJEI5qSqulxTn0n+nKtPntxY=; b=cB83K9Y78mjiwHgaAswznyPOmoHZ2nGwf580ftvgzlGo14l3wTBESDyv9eFvYgCGZx 9tZ5pVUZc9xvrkdIeuMiCinWSqMzuYCD9f3j8/KsFQp1IG9MigZBq+F9bBNHUOeJzkk4 Y49OQbpTqD2uBqPHwshMS5rLa34Ai7ZmmUmaa2jCmxam3da+s2CijZfzrSQMXO4M6BT8 x9F17iAaE7HgoXPM9BdkHKEOZL5Rym5DDoxFly33HR/SAL3UBx/e5fNz3SL2cDy40ZJu 2TPOLXfj5CJNO3yvJVSwvK+Lf7YmjQGE8gF5jiTaXLWsHJpfKNkcl8+jhtQZiuDpbkRF XISA== X-Gm-Message-State: AGi0PuaSVjozdrcgZcFQ16Birzpy1XcgkRUkNnadjnrRS+R52P1fkrl7 C0bP/sqpI9P2CAgoUyEQJ29nE2P6FjLvFMLPkHM= X-Received: by 2002:ac8:468d:: with SMTP id g13mr10321977qto.59.1588800994307; Wed, 06 May 2020 14:36:34 -0700 (PDT) MIME-Version: 1.0 References: <20200506205257.8964-1-irogers@google.com> <20200506205257.8964-3-irogers@google.com> In-Reply-To: <20200506205257.8964-3-irogers@google.com> From: Andrii Nakryiko Date: Wed, 6 May 2020 14:36:23 -0700 Message-ID: Subject: Re: [PATCH 2/2] lib/bpf hashmap: fixes to hashmap__clear To: Ian Rogers Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Networking , bpf , open list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 6, 2020 at 1:55 PM Ian Rogers wrote: > > hashmap_find_entry assumes that if buckets is NULL then there are no > entries. NULL the buckets in clear to ensure this. > Free hashmap entries and not just the bucket array. > > Signed-off-by: Ian Rogers > --- This is already fixed in bpf-next ([0]). Seems to be 1-to-1 character by character :) [0] https://patchwork.ozlabs.org/project/netdev/patch/20200429012111.277390-5-andriin@fb.com/ > tools/lib/bpf/hashmap.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/tools/lib/bpf/hashmap.c b/tools/lib/bpf/hashmap.c > index 54c30c802070..1a1bca1ff5cd 100644 > --- a/tools/lib/bpf/hashmap.c > +++ b/tools/lib/bpf/hashmap.c > @@ -59,7 +59,13 @@ struct hashmap *hashmap__new(hashmap_hash_fn hash_fn, > > void hashmap__clear(struct hashmap *map) > { > + struct hashmap_entry *cur, *tmp; > + size_t bkt; > + > + hashmap__for_each_entry_safe(map, cur, tmp, bkt) > + free(cur); > free(map->buckets); > + map->buckets = NULL; > map->cap = map->cap_bits = map->sz = 0; > } > > -- > 2.26.2.526.g744177e7f7-goog >