Received: by 2002:ab2:7104:0:b0:1f7:f6c3:9cb1 with SMTP id z4csp11340lql; Tue, 7 May 2024 08:30:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV9TveZ0bAiXbPzJ7C0rpvMu7aJST0+5tlsk8gpAEE9NFgR7DNrcYpLDjvJy7EDPUI5G6F8iRJx4T7Oy7m9w4TVRksXYcntvyNBNKX4uQ== X-Google-Smtp-Source: AGHT+IE/Cx0AEeKmpCpy/XFc7rrCyeHNG1Qt2RjLGl1c++SxCSKirBy1yJzI3fLwa8imsGlAI7wU X-Received: by 2002:a05:6870:a790:b0:239:8e67:6f10 with SMTP id x16-20020a056870a79000b002398e676f10mr15742242oao.30.1715095805863; Tue, 07 May 2024 08:30:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715095805; cv=pass; d=google.com; s=arc-20160816; b=SHLFFLzu9ZOPX37YqrwnYqr2kS6YEvwTo8s0RLE7+8Rulx1VDJkeOevDJnW1uikJud 42TOQML34Z6TEkHHNVVllgNjp4z8znA19guaygcLWP+BBO8qw6W9rK8KlA3x6CSZEwvR IQ0LTYMwsrDDPgUd0TytXjivX13fR++oqUhmVZ6j52HRpoqepn3C396XvsgExDdZuqk2 3VcRqueq3zmjl9CyatYTE5a0SkSuzQYD1D8STWfZI0xcaS3Na/DF6+XqzgVyqG6Soakv ole7KjvqEibYLLK5dZqTbgkJ/xpdIsJQ9biu/3CFmtX6iIEepw4CxHabzE1Zuq243t7q ahhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=R9m+M5Zq8MH4FRXUdK8y5KRdxmH8LgFgmpy+/08qytw=; fh=0iP7KC8U49yjVojUGKQe85v+Ko9+oRjsym7pRdPoqlg=; b=Zuzs8eEDiL9MSd5MtZaIO2q1DM4ZeBzHV7zhHR8eihVUjvEt0/QNqb5sZYCgj7FfCV dijPgQNVJ/QAPFdMeJN32TX6ls0vaK8SMQCiDNl7x6p5Vr8zzD1SR/MSgySMO4QK2yg1 QN94WkJmHuCBog0DI/6h6KnFsyaNOeA5Im2i/tzbm3hjHf6FaWmOuLHd65Jb7rWjlq7w pnQ1DyJcNaeHT7jLTr5IOlGWMGlWnPZKFMDxgeUIfeLlsARYwQyOEp5QqecK1boXTiy1 siefrBXbBsrlsNI/8oqDomfUoqeepBO8pFPaVAU+7jIJJex2gfyZfjb5Fwyw602sYbwA foTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dv5hBkoD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i70-20020a638749000000b0061b5529ac93si10190054pge.338.2024.05.07.08.30.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 08:30:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dv5hBkoD; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-171639-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171639-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C056BB26A40 for ; Tue, 7 May 2024 14:59:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99004168AFB; Tue, 7 May 2024 14:58:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dv5hBkoD" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0C65165FBB; Tue, 7 May 2024 14:58:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715093921; cv=none; b=AIrpFtyT4zSVXpIuVJwvLHQto7vm5WVo/AA28C/5fTJ87/TAPK3uX2Q5voJ1qjGPPFglI7IMjHjCZFmpmCCDCNlb38xtp/gIX60AVw0JWnEjN7FGzo/rqQQ/AdijCDxSwZJjg+yym1e1cJWNq/PC4yapPV4pX/S4FGIXf5+FBQU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715093921; c=relaxed/simple; bh=BlgGobMZndwfwOk3KudlQAze0gy+zqr4ktG0u2cvSuA=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=relgHke2BsLYRoc84xMzJwcO9iISDY8btc6Y7EVz7e2XCjSwPMeBwUoszRNASiPcC2Y5r/7mW532iieKFCjb9erDbCxeqHBghhNWnWE4wA/5gqV/giBvZFGhkuuGGDVPIRY6ruXDG18ox53iOu+m327AgeQQTReLc07+lm2YfqU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dv5hBkoD; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4EE9CC2BBFC; Tue, 7 May 2024 14:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715093921; bh=BlgGobMZndwfwOk3KudlQAze0gy+zqr4ktG0u2cvSuA=; h=Date:From:To:Cc:Subject:From; b=Dv5hBkoDatfLK0RnKlftZWS6xf5XN+VbQH8YTRBrSGSxuFNF/Fdxa0dIZIepFcXrd +rBvI6X8Ta3+6p0Kq6QKvZ0UWWd+K+zZZp+Dq11yZEmecYiNYODyruzBgYQUdc5Yc1 ya+SDUcMIwKnmj6GjArLT4BhzusC2KPtze9Y05Uit6P9vwMIejoi8o9vl/0qPdnQ5j /mMf+ZYrG7SYwfvd+3uhcvqMIWbElFXLOq8+lz8j5ZKDecBWS4r7t7c7lwbXKgJZOO Yi/ry1VsWO7dco0VvOr9N/ZDp5qB0sqZAqsl2iekG0D+23YOG3fwL9HGhoqqGfZ3ka OzCD+8p2ILhmw== Date: Tue, 7 May 2024 11:58:38 -0300 From: Arnaldo Carvalho de Melo To: Ian Rogers Cc: Adrian Hunter , Jiri Olsa , Kan Liang , Namhyung Kim , Linux Kernel Mailing List , linux-perf-users@vger.kernel.org Subject: [PATCH 1/1] perf probe: Use zfree() to avoid possibly accessing dangling pointers Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 'perf probe' codebase. Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Kan Liang Cc: Namhyung Kim Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c index 019fef8da6a8e60f..003a3bcebfdfc2d1 100644 --- a/tools/perf/builtin-probe.c +++ b/tools/perf/builtin-probe.c @@ -325,7 +325,7 @@ static void cleanup_params(void) for (i = 0; i < params->nevents; i++) clear_perf_probe_event(params->events + i); line_range__clear(¶ms->line_range); - free(params->target); + zfree(¶ms->target); strfilter__delete(params->filter); nsinfo__put(params->nsi); zfree(¶ms); -- 2.44.0