Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp190013ybj; Wed, 6 May 2020 14:55:41 -0700 (PDT) X-Google-Smtp-Source: APiQypJdz9U2T70MCPfaAgxnAYk26SfTqXWz6OFbDAl3aMhoYtWzvVOs2k2u84bL+qZdE9WU5D7a X-Received: by 2002:a50:f98c:: with SMTP id q12mr9530534edn.172.1588802141184; Wed, 06 May 2020 14:55:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588802141; cv=none; d=google.com; s=arc-20160816; b=GiB1OQ8Dn86wTBcmPNGIg3Aku5okI6/fhfbOr2RoZKQq6UBSUQs8az3ux17xl8/yo6 xYv/SzMveueQ5qaz1ojDgnvfvS3hdx+JedBhPOOERkt58pBWiYYEgwObtzWqwjISBAwV RdZZPXPjLZcw11zw1x4ljmBIFAgzojeoVA2UNcG6ojLdsbJ8ndoHNX2gZvh4xkQlI9++ /zOBL2USLBz8VALCYZVNhVK2EuaeVwMr3Yw9jMgUuaBKIuijxv4FfCFnCaHti3Nfu33j Yek3FZWOtPfusrmtIv+1+YV/Di54c3goVt6fjAFgiZd+SEd93Cf62TXaEhurqCMx82mi qO/A== 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=v0EebI0wRb/tvCNXlsGxxNrmG0tMY7mj+ffgbYSbdE0=; b=MB4VHtWU33Cf5lW7WVKxwYRKHoEsWiF7AYFArYb5oBSogi2iFx7fY6Pf9/qcN4SpQb d7/Gxf70yiUTpm3bk7g/J+EEh8Pyr2v9AkBsNCmLhj5eUkjJfDgwllXJHzQoaR6KcSok nI3KuFJE/YH96+YSmrnBMzTPjyv6g7ylO+josPnl9rQMr2IpEGhylUe7Fnr9jnmcqoZk zJ5Ttf8RBPyLOZpM9G86sn1HUz4GAGsKGHhWppAlVnnB8FO4wR5xen6ug3VbZKtU5G/U vmNDNXw952WMkPSN/VKDRjwQSby0sojpAa7DauuJVE1rbbNn7+lBPdqp/Ww4jS4lN3QQ lnPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UFXjgemc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h15si1776160edj.37.2020.05.06.14.55.17; Wed, 06 May 2020 14:55:41 -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=@google.com header.s=20161025 header.b=UFXjgemc; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729809AbgEFVx4 (ORCPT + 99 others); Wed, 6 May 2020 17:53:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729665AbgEFVxy (ORCPT ); Wed, 6 May 2020 17:53:54 -0400 Received: from mail-yb1-xb42.google.com (mail-yb1-xb42.google.com [IPv6:2607:f8b0:4864:20::b42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72874C061A10 for ; Wed, 6 May 2020 14:53:54 -0700 (PDT) Received: by mail-yb1-xb42.google.com with SMTP id i16so1796962ybq.9 for ; Wed, 06 May 2020 14:53:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=v0EebI0wRb/tvCNXlsGxxNrmG0tMY7mj+ffgbYSbdE0=; b=UFXjgemcco3wS+VML2EXMGYsw4wBSNxjKeNKGP2VQLQpBCDRbOWS3ejRsjb8/MLwVB i44cyTIAOyIGEL+wG8PZ0kJ9esTwBGXdx1zh1tGCCnHhNK7xnhqyfssDgOfJsCnc6LBq Y/o2XLAjh5ZzlmDVZ4/xuF759eOvsb+adnnL9vX2PtjVSDSxvuwI/7S3i836Ws1zEaJr HttwrrK4q8cCP7sMvkDPaC9kC2+rXJ9azKf15LY7RvcFueycEHCNZ6g32E2lhLfRpyFn GwI02VwqdYfZze5r4HE4SrZYbdMcWEv54HwOEWeME7Qh0f2TtH+Y7LpKH2iSuGul9/Hw hjrg== 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=v0EebI0wRb/tvCNXlsGxxNrmG0tMY7mj+ffgbYSbdE0=; b=KlKBCPrw+oKa/PkY27SDDg8mzG6zwzHUicMDEo2ywB85TZ6LnD/RvXf7g0LmZtm6Eb fiTlWdAyv7YkN4XNNE9GxWxYz60jCIF7arq4GEuLM3H9QhNDnpwJC54D9JB/h+mw+qDw MhLW9FpN46wwQLzMomjH3nSvFUDm1YOxbar+WWwQ/XZAN3S9BLKaWKkKivafW0csrumn nNtSo6fJQF9czpNmCmUggl6t0Q13cSaNLeyoWTRNK+nrX2wd34anb9Fwh0yzZ5Q++86a rVSoXHokf3dNIPrZZmNk9J11eeK4Qn1MejhiRkv2aFW33LCuLdvtIJCtIASBAtXxEm+q dG6g== X-Gm-Message-State: AGi0PuZfI1Yr26j/8grwCjV1YWlVkLaiVWJWiVo9rDGYTFipagsTRyFs 0eqldP79Ahh3X0EiwVUOM7GEddBYNBuXFma3GduHxg== X-Received: by 2002:a25:77d8:: with SMTP id s207mr15709759ybc.47.1588802033385; Wed, 06 May 2020 14:53:53 -0700 (PDT) MIME-Version: 1.0 References: <20200506205257.8964-1-irogers@google.com> <20200506205257.8964-3-irogers@google.com> In-Reply-To: From: Ian Rogers Date: Wed, 6 May 2020 14:53:41 -0700 Message-ID: Subject: Re: [PATCH 2/2] lib/bpf hashmap: fixes to hashmap__clear To: Andrii Nakryiko 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 2:36 PM Andrii Nakryiko wrote: > > 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/ Thanks! Ian > > 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 > >