Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1416446lqd; Thu, 25 Apr 2024 15:14:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV+mVeTVkUhvx/sPtMxTkRg005eiz/qm/XCL57Prlp5LvsFydV690dxyfi0UsK461QhnIZ4mo9SY0lM4cjdTPN3iOpL07ROjFDAQ9suGA== X-Google-Smtp-Source: AGHT+IGFzZZx+W0/6ztZLqgyPyE05m7MuuqhRmEysJPR1tzWQk6GzPPElprav0/wd44BugHr0pgJ X-Received: by 2002:a17:90a:1fc6:b0:29d:dd93:5865 with SMTP id z6-20020a17090a1fc600b0029ddd935865mr867416pjz.46.1714083282911; Thu, 25 Apr 2024 15:14:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714083282; cv=pass; d=google.com; s=arc-20160816; b=EcuLV9pByg96dLop2pQNBvu6gPo8knVRc1FnU3LeoUbRk3IjlsvKgVyhC5/4I4lMt5 DNSHuUnP6KfOU7bjE3Hr/nJGwGHJA4Q+kzbRlLdV+ROMIFRQpiJlY8bzs1coSasLU3pQ woZVvmGMEFldF0RAKUzxoH6AHKZ0OumEAPiAdB8JCMyh9Q2qsYzyrOotZCWJif2W58kW V8/HSSFIkzdZ7LPxoQhJjEKJaaHtXqQNox1BjRsMGNLdQWzqGhIsDoRE2ov7A4+xNQr+ k/abmCTXPecGMX3aeDudC/NS+DLTCnN69JQxqoMUKQCvcfm+Qlkm3uqucWdfdY278jYC XOyw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id; bh=irdFcs02TzrCictDx6qsu9Axf3yzWpIF8qRgj9fxp9Y=; fh=td+0v3trrmPV4qP41iyJFurZmnin3cs+QQ90oVx+Zok=; b=NOYHh+m8k7Pxt4aYWeZPtr9Wirl4GcMfu3sl9giF9D+AEYmGInjf1Apj9wKreXpjH5 Q05DvA1seZTrlwI0pZni4d4QS3JenAxSbMb7jCGrfoaEEZAYs+ElFyei0ZCan+XgTmwI yLFU+qXdUculQqMMdRDMxBNcv6XAhXOWKWWD/0zjTs7GQfmUeS2WcNLU+6WTfm43cGa8 k2tJdda67gtSt4YLYve0tMT8ROWNzQxyerLV5+pPNQnVT9q9z0FVILmQo7XY8tQGwwn1 k0a1unQx8zpeoo/FtvSn/AkS0r/zA82QOF9MBFG9LLHx5DG9JLlFm6yi1ZrVCl7Y+LgC 7sPQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-159294-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 j11-20020a17090aeb0b00b0029ba20feef7si15567985pjz.188.2024.04.25.15.14.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 15:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-159294-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; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-159294-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-159294-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 A7A72287E89 for ; Thu, 25 Apr 2024 22:10:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80E4716F839; Thu, 25 Apr 2024 22:02:46 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BEB93153BD7; Thu, 25 Apr 2024 22:02:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714082566; cv=none; b=ZLePe4Zxa81V8a/Z4k59SP6Ix9TlewNK4paZ851RTOxF9sS/INNpzzBZLSjSGq3Ss1DsYD7nj9mUwBeo6ScIqWqeEOJqlVZKGhKTOuUn5pmAwEMUR9DaCjP8luN46IUulNxB/vRtl4Dv6Z6H7tH8V86iYGW1MkvU40DnD03aexc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714082566; c=relaxed/simple; bh=MF7/MmMr8a4nNSERUdc/jjo1OcVPHWAGSNEofngKwPw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tFB/l0C6jZz9YIDIB3HJpR/BM4cUdObOO0C/cH+/x0bj36SwsENIKpjDeizVcDmJnD8bFBBP4sSNUC28d6ZXxSsIwQjEhFyquEUWSu7suK69Tx3hrMheuS6eiU3/sE07+i/yNP4Is1hsMp2zzTO1IYzQfy46RED5haiXHEKu9bY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 149CC2F; Thu, 25 Apr 2024 15:03:08 -0700 (PDT) Received: from [10.57.64.58] (unknown [10.57.64.58]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CC46B3F73F; Thu, 25 Apr 2024 15:02:38 -0700 (PDT) Message-ID: Date: Thu, 25 Apr 2024 23:02:37 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/3] thermal/debugfs: Free all thermal zone debug memory on zone removal To: "Rafael J. Wysocki" Cc: Linux PM , LKML , "Rafael J. Wysocki" , Daniel Lezcano References: <12427744.O9o76ZdvQC@kreacher> <4918398.31r3eYUQgx@kreacher> Content-Language: en-US From: Lukasz Luba In-Reply-To: <4918398.31r3eYUQgx@kreacher> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 4/25/24 14:49, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > Because thermal_debug_tz_remove() does not free all memory allocated for > thermal zone diagnostics, some of that memory becomes unreachable after > freeing the thermal zone's struct thermal_debugfs object. > > Address this by making thermal_debug_tz_remove() free all of the memory > in question. > > Fixes: 7ef01f228c9f ("thermal/debugfs: Add thermal debugfs information for mitigation episodes") > Cc :6.8+ # 6.8+ > Signed-off-by: Rafael J. Wysocki > --- > drivers/thermal/thermal_debugfs.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > Index: linux-pm/drivers/thermal/thermal_debugfs.c > =================================================================== > --- linux-pm.orig/drivers/thermal/thermal_debugfs.c > +++ linux-pm/drivers/thermal/thermal_debugfs.c > @@ -832,15 +832,28 @@ void thermal_debug_tz_add(struct thermal > void thermal_debug_tz_remove(struct thermal_zone_device *tz) > { > struct thermal_debugfs *thermal_dbg = tz->debugfs; > + struct tz_episode *tze, *tmp; > + struct tz_debugfs *tz_dbg; > + int *trips_crossed; > > if (!thermal_dbg) > return; > > + tz_dbg = &thermal_dbg->tz_dbg; > + > mutex_lock(&thermal_dbg->lock); > > + trips_crossed = tz_dbg->trips_crossed; > + > + list_for_each_entry_safe(tze, tmp, &tz_dbg->tz_episodes, node) { > + list_del(&tze->node); > + kfree(tze); > + } > + > tz->debugfs = NULL; > > mutex_unlock(&thermal_dbg->lock); > > thermal_debugfs_remove_id(thermal_dbg); > + kfree(trips_crossed); > } > > > > Reviewed-by: Lukasz Luba