Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp818874lqo; Wed, 8 May 2024 16:40:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUe5bBNXYRd/CnLVF9lzlo+aYxQeOtjBT7Gv56qsOxC6z4LkgSzuZB+jsDf4nIdawWPLoe6vSXOAEiVvtr0tOWgTFXS6mB8DntVWH2Yag== X-Google-Smtp-Source: AGHT+IFt2zm8i5aqEo24lBtIMGH8yKNsATb9bMbvU6ehfQRJECDjqE7kDTo4QJBgSGdujx2WcA6r X-Received: by 2002:a17:902:ea86:b0:1ea:f9af:ee99 with SMTP id d9443c01a7336-1eeb01a608amr37648365ad.25.1715211636824; Wed, 08 May 2024 16:40:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715211636; cv=pass; d=google.com; s=arc-20160816; b=l3ew/NfZla4DYQZK1Sd7AqJqVDd1aEv3gE6N03qQZ0oNnwlkrKy79twWst1Nha+k9b 80R+1JnVAHxdQDUEzSOYp66VLTQ86sOwXfcfiGRoM3n8WwYU/bGF0PTpma181vJDCZMR 3BFc8sIpfLXvSD5pyQsgXR8h0VT94/hV1z5W47s2Y3sjLTqUGaLwU0Y0zvi9qjFk6OkF 2g9rk1PxSxsb851TH0BGI87TnIDqZU5uopirFpON8LLRJSHGKBTlWoS2Nz/DNdGY6iWY XzfB1t+AB+M1CFd1iuujzfRUhO0kyUe+sUHae48f/WejyoIdNnQxdgxVLezpwbe5E+Ka jpaw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=6jATuZPpZr2U9Ga/FPqShVFC6Jp9UCpaINafz+jyTdg=; fh=eBQvJTsC2hIsOSxLrTTZOkIkiw8rFrbuVUSH41QTiZE=; b=Dsw6D06RTcg0Wn7mE9Xj8Pu+GM8HFiDjP+EiC5gO8vEoUkWNLbh1NsYCdQ7vuw3xKb m8CyVJd4LPgiO56m2bYb54WyS3J3g7InrziLsPElbuFKP/PiPSJi1m8uvss+k1kXOx/d 4kIo61DZgl8BwEVNdyHWdjrrk8D9NcTIjvPeevG9vCewqMHz6DfWoRdjpNI7MYwQd07d a9mZYL6mL5nZ9x0sCH1szy7MO8R3ecQVb6x93go+7m+r529gdA92t0i9Ak+QwzZwGwVq IZ5z3vDZcCq3wPFgN0j5JyM9kCB0RjYIBMqptHbc1Xo31BWzS7zvu3JWgpjAScQIa77E nakA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2C6oBAML; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-173934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0c13f97csi1822405ad.466.2024.05.08.16.40.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 16:40:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-173934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=2C6oBAML; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-173934-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-173934-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E1920283C57 for ; Wed, 8 May 2024 23:40:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1D88132C1C; Wed, 8 May 2024 23:40:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="2C6oBAML" Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB0701E89A for ; Wed, 8 May 2024 23:40:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715211629; cv=none; b=ZRBQrNv3KgOQDWjKK3egR1RzVHAQUQ+O7JAfpjvnS1jFH0jZMtLRHAV/NRACG4fT4esrahw7Mh3Wl77BCR+Fu6+bssg6bYe624MoBKCc3nE6h9uP3C52BWIKrL73Z+bI2SV2qveY1fPKezJ4l9J0jQc4ZM5eiZmY7Q3Nn0VHAfk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715211629; c=relaxed/simple; bh=+wtLczbdW/FxsW0T85EByS/LSghiVmxUEfbES7DYGDE=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=chhJPm7/1jvwZe5u6XWq1waHHxdNsFrfL1YFmccnBxgPhQ3jO/oU8/+UzUm5FRhuc4uwTnmCkjeyAWFVBE/LumNBJiYrPmSgu2JHuPW31PtP/v5boFQYg7Iy4On115sjs+AcaR4TY2EUwo9sZ+fFro3z0WU8aZJsYMygdIQiNEg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=2C6oBAML; arc=none smtp.client-ip=209.85.160.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-qt1-f170.google.com with SMTP id d75a77b69052e-439b1c72676so94221cf.1 for ; Wed, 08 May 2024 16:40:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715211626; x=1715816426; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=6jATuZPpZr2U9Ga/FPqShVFC6Jp9UCpaINafz+jyTdg=; b=2C6oBAMLKFLjDyWQu95xlozNq2SrmzrLrPvjXVphkNrSmf7R7gyNzz3OBO7EStBSsv MgrQ4aGqBiEgBhC45gdoos4kov3NzbcDv4Nq2clnIt6SqSlO+Ji676gyaGt7IuPkKIeX 351c/G9xg1ArAOHjcHg9sTYk+ZYMiJjXA3VYHsnvspCw5HUjR6L+iOiW5voGNyVjyXTm moLBEAWn0NGGrmF4Z2nl9DPWZ3Lg69nMeO0BFid29L2RkToEX88wMxrB61Oq3C4LXMNM FbHOvgMjtYw7pXNDMweIFrD0/xJf8IUQqXwpQFNALJLR8pvlDE+xr5wvipF2G7EYIsdD Wu1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715211626; x=1715816426; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6jATuZPpZr2U9Ga/FPqShVFC6Jp9UCpaINafz+jyTdg=; b=kzpwIY5u6QlJBFDlBZIsGW8hwNV+wHSes+L5XbCrglO4mnbsmeHxgJ4X+6WtwUx5EV naZjtv3t16nqUyaGtKcxigRdWR0lmXmib8fiJ3pwQoknb+WCan9CZx41NmrfuyWLqMVU KqkfhShBpyjp2Y9exUVSLGWRB2sjXAqIK9aUUp9IgYHs+5aGmB5CVDIXpni8nAOCj5ID Z6g6bmb9IA9gJjhrTsIBRjsybvfIyca52N7S7M2tQIl7joz80mCEg0oN8SRYGFDKwa4C FN1zLDoPO0a7K275wWUaNFZXKjScPAfLbJyf5+05YnS3/X2XiCocat0QCloGzvn3Q023 lnfw== X-Forwarded-Encrypted: i=1; AJvYcCV7vkFhfvAMOIOB3MoPumyOHMtlCDtyGyF6zQLqYhpGGr0u3mKG8C4R+eKk4KNV5PnkhrEpsslTsieIGoewJFLTeblXzrpnHMcqUH7u X-Gm-Message-State: AOJu0Yxyy5f1nCtzPqRsPLN7hzLfp8fEQ749p+gR0vnp5aEq+yXkmqil OSYIphTxudhZs6vRHhLaw91qrj3z1HrBLlNwX3485DXHMufkrRl7RixCpM1altFlWnX9X5fpog9 zjZeqnrem8FI+orIRN7Hsytp+dwiRr3+uOfg3 X-Received: by 2002:a05:622a:2283:b0:43d:e9ce:63ad with SMTP id d75a77b69052e-43deec6a98dmr1246531cf.0.1715211626478; Wed, 08 May 2024 16:40:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: In-Reply-To: From: Ian Rogers Date: Wed, 8 May 2024 16:40:15 -0700 Message-ID: Subject: Re: [PATCH 1/1] perf callchain: Use zfree() to avoid possibly accessing dangling pointers To: Arnaldo Carvalho de Melo Cc: Adrian Hunter , Jiri Olsa , Kan Liang , Namhyung Kim , Linux Kernel Mailing List , linux-perf-users@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, May 6, 2024 at 8:12=E2=80=AFPM Arnaldo Carvalho de Melo wrote: > > When freeing a->b it is good practice to set a->b to NULL using > zfree(&a->b) so that when we have a bug where a reference to a freed 'a' > pointer is kept somewhere, we can more quickly cause a segfault if some > code tries to use a->b. > > Convert one such case in the callchain code. > > Cc: Adrian Hunter > Cc: Ian Rogers > Cc: Jiri Olsa > Cc: Kan Liang > Cc: Namhyung Kim > Signed-off-by: Arnaldo Carvalho de Melo Reviewed-by: Ian Rogers Thanks, Ian > --- > tools/perf/util/callchain.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c > index 68feed8718096f78..1730b852a947400f 100644 > --- a/tools/perf/util/callchain.c > +++ b/tools/perf/util/callchain.c > @@ -606,7 +606,7 @@ fill_node(struct callchain_node *node, struct callcha= in_cursor *cursor) > call->brtype_stat =3D zalloc(size= of(*call->brtype_stat)); > if (!call->brtype_stat) { > perror("not enough memory= for the code path branch statistics"); > - free(call->brtype_stat); > + zfree(&call->brtype_stat)= ; > return -ENOMEM; > } > } > -- > 2.44.0 >