Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp269656lqh; Mon, 6 May 2024 20:16:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVbWm0sax7sSz0/1JsDeJHq4a3IMYgBml/GQumv4rCHtfFcuc86JeBUqJTiuPGqHdNUlKc37QON6wpzZyr/tYogZfYUvHHTV4qgXQ+06A== X-Google-Smtp-Source: AGHT+IH15vkmO7cTcCk4LVBcOcAwbxYmtOoNlFSz8eOFyfjbetNdVw7sAgW4Y/Sq0Q+YjuG5RRZA X-Received: by 2002:a05:6870:bb0e:b0:23f:6353:a927 with SMTP id nw14-20020a056870bb0e00b0023f6353a927mr6622070oab.39.1715051762019; Mon, 06 May 2024 20:16:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715051761; cv=pass; d=google.com; s=arc-20160816; b=a6Bl0JzHHUUFRQkjdsUl/Idv1TNfVtYV+q/pTTP+hWH9rtiksxFWj2ieuEOGsr3N4H +2/V0Fnc2/MCpnJf48KPk/5Az6a8N6Ecw7ws6NSqw3PEi0wWB8jvYV3Upgu00eCW9udA at5o9aHLziZW1I3rDo30RvCulDs7L9KUjPfN3QJH+wEM+ePYflk7LLqWBgsXmB/xsEp4 HUgltgRzd7DHJ3qwAHTj5fiBNVvXYEhrZmYSwGoSjLjjYNIX0ZJoEkpLpzJF3zVjGh8Y X8FQsO/K+a8W6w/orAmNJkl34HzyyGHx9oesoHFQ5JosrL2iBhl7tpUXgNT5gGvj5P+/ YWuw== 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:date:from :dkim-signature; bh=ats4eFWKO0oX0tbMb50Cxd74w7mweIFzoDVzLRszzCc=; fh=2Z+LEh3B5mGLrb2ls/W9IsuBoXWrVhwWl1NJSr2bs5Y=; b=e6WhiX8cWGpNKXzc1SMaqG9ol7MPjPGLjPEmFPefKAinnR+lzqpCVETl/GWOCIU9xF 9HNvIrnsocFKmpuHbuBXPsOUUtjQa1228SUZ3DQMFq5HU6/ScpgkeZWzMuRjVxIhB1i5 gJx73mPJSfqUYJPeGsEjp7ywxKfgdcdGAO711IiKnQLafHMPDhaoxjJ91lfg9k+AFFl6 v2C+TdSD0fKvMxajss2+xeWUKuCU3H5IdX75Pa4/6hVFaIPoAV2H7IpXrcGgVSY60IkA jV+WGclVSBImDsZcx35/E1F9RPcKF8I3byHw8wWD6GfmmuXfW/vPVEJICIY5iSnGIDrW B59A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=C6WHK7QA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-170607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 u64-20020a638543000000b0061b37e7f865si8934631pgd.583.2024.05.06.20.16.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 20:16:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-170607-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=@gmail.com header.s=20230601 header.b=C6WHK7QA; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-170607-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-170607-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 8C5F1283BCB for ; Tue, 7 May 2024 03:16:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 243AA41C75; Tue, 7 May 2024 03:15:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C6WHK7QA" Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 1D7388F59; Tue, 7 May 2024 03:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715051754; cv=none; b=g8bHUxhCbVAVDx8PDR/SVg72SfqaaUUtiv5JOcadfXUoDXAMe059iXspvo3NjQVoPew/hdSfUKetUMoxPfxHszChCjpspgq+GY2zi2e8pGJRZSlMgLaA4BbIo+Jdac/95f0Ww3CNi4hcDe6M1rsOxcijQBDOmzD0oEw7eqYeibg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715051754; c=relaxed/simple; bh=AHH/m+ka+Qb6OnM3YwkZe2xFH0HDbhoI5R1oc5Qceuo=; h=From:Date:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=QqiSWXd1MS+M6GoVbIId9mxzBaKT/9jyxZgqCJMj01d0V2JB71V7GWXdiz3rA7GeUap1KlJpLCYBGQQ3Mse7EAnJPxa0PmEcdsFy1ds1UksVNtsim279mmGJ9FZj4YRn25tYcJm8EcdjsJ8ajYODQ/NTfOK+z9Wej/mjvvlSUDY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C6WHK7QA; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1ee5235f5c9so8376175ad.2; Mon, 06 May 2024 20:15:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715051752; x=1715656552; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:date:from :from:to:cc:subject:date:message-id:reply-to; bh=ats4eFWKO0oX0tbMb50Cxd74w7mweIFzoDVzLRszzCc=; b=C6WHK7QATNmjzUOJDOq9TYFLILoi7Uq8KPOYzgHAd9TsvlUmG1WoRZUiZUHfqaTPEF GMVzs8UP1jfFvX/9RtiKFfJ8E4iOgyIT5M75SfuCJuwI0nYjXxkMZXXYjw9bCljUeNNC KJ+oZQsF+LyEp1/NoIPOPBPFeoh3XoTKchyXCGD0eqASE+h/IzCnbH7qeQrWvF7X8MAT 5r88V25USzOWfg9R7awPxINUfYPuegfs9kvIFPH+I49dNPwxoF2fDvKINWn2DITuJPFB mrB4wenJ5jKiEkIQNmi9CpAPfYHrZ6zzK/LqtlNW3kPzW+YfhofgtvblzfKVTKsgi7G4 Ivcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715051752; x=1715656552; h=content-disposition:mime-version:message-id:subject:cc:to:date:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ats4eFWKO0oX0tbMb50Cxd74w7mweIFzoDVzLRszzCc=; b=b7Frq4ispRZPMDiFK1VuPQIUMrC3zJ8M0gn7flFcgQz2FJmgbSk8uhWN+pNnxawCQf 4LowU1vuj3RBCHbZxTOtQEaYXCR2xBjRG/j2akK9w12LY6RNgxrumCUgZQXnLRoh0xPa C+3CZhLQTekniyXv4k/YqFNab7ZdpJt5/ImzoEsMtjMpRJal/6A3s8kj2UZZ7lH0DT+G xUvpQzLEKVcRlmOrYclsKTm60Z/D2slrvV3thX41NKC6k25xdDsf7qYgC8c8UUx3vIGH VwyiS3RLpMWO7PbzmEXpGzjSa1lEjIHgRcICQaC1yev8t7tWIGVlfijEPm08eN+iqfcd HJKg== X-Forwarded-Encrypted: i=1; AJvYcCWsv6GKwX6QywNl5KrW7rS6UpY+1ZOMTMk/a9I+9Fa3yntlCcJp7f8V4IwGclEOVZ2OwRo9S/C36f17A1eXPGx2nOph10B59mLJP+VPzSy3wxBw+BGI9jRjCDRWpNTFatavzXryNeeP5m0Fg9/uIw== X-Gm-Message-State: AOJu0Ywhp5XjOh/hpYmq9ej+MU7uGO+J7oa3OgFbMm2WESUb6llMOM8w vK3OfbpDuYHwsZMv3YSrZfy9SRiYMZ6qc0WZoQIrl17s7jfI85jF+8rvYHLi X-Received: by 2002:a17:903:11d0:b0:1e8:26e4:d089 with SMTP id q16-20020a17090311d000b001e826e4d089mr14805245plh.54.1715051752198; Mon, 06 May 2024 20:15:52 -0700 (PDT) Received: from localhost ([187.19.173.21]) by smtp.gmail.com with ESMTPSA id i18-20020a170902c95200b001ecbc8137bbsm8970419pla.131.2024.05.06.20.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 May 2024 20:15:51 -0700 (PDT) From: arnaldo.melo@gmail.com X-Google-Original-From: Arnaldo Carvalho de Melo , Arnaldo Carvalho de Melo Date: Tue, 7 May 2024 00:15:48 -0300 To: Yang Jihong Cc: Adrian Hunter , Ian Rogers , Jiri Olsa , Kan Liang , Namhyung Kim , Linux Kernel Mailing List , linux-perf-users@vger.kernel.org Subject: [PATCH 1/1] perf kwork: 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 kwork' codebase. Cc: Adrian Hunter Cc: Ian Rogers Cc: Jiri Olsa Cc: Kan Liang Cc: Namhyung Kim Cc: Yang Jihong Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-kwork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf/builtin-kwork.c b/tools/perf/builtin-kwork.c index 0092b9b39611d7e9..56e3f3a5e03a2d66 100644 --- a/tools/perf/builtin-kwork.c +++ b/tools/perf/builtin-kwork.c @@ -2230,7 +2230,7 @@ static int perf_kwork__top(struct perf_kwork *kwork) perf_kwork__top_report(kwork); out: - free(kwork->top_stat.cpus_runtime); + zfree(&kwork->top_stat.cpus_runtime); return ret; } -- 2.44.0