Received: by 2002:ab2:6d45:0:b0:1fb:d597:ff75 with SMTP id d5csp31978lqr; Tue, 4 Jun 2024 19:48:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLCkjZb4jGpODlhR6njtCSOeyQaKqAuqQuCKOTREpFuggDpEIh45sKRGhOmjyLCvjKnOz50zHiqkLS0mGD2MbU79lKiy3sKHu70z1sgQ== X-Google-Smtp-Source: AGHT+IHkyYn+pY1ssgeRn6qLPrTGfQmNvuEogBd6o6T5ixOgkAoXRFiP1Mziv3n+XFrALH2JYKtj X-Received: by 2002:a17:90b:4a05:b0:2c2:1776:3a6a with SMTP id 98e67ed59e1d1-2c27db6a465mr1255856a91.44.1717555718411; Tue, 04 Jun 2024 19:48:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717555718; cv=pass; d=google.com; s=arc-20160816; b=t+tWw94WsnCVs7v0tZKBruRWkNCG2QT1MNWevzpA0+wTNrmrXCkmSp2UNvz9pN2aAU XxsnObApnsT9lGnQ+76WCrhT+Gx37zWbxhiU1rtD0qgHvowRGrDpUjIqc6GuIMYb7q5A VFxn2SXbA7qGU/KJ9H7WGZiasWH9dDbLApn9lQcZgWjcrQu5bFN81LQtzvCLne0uPkvK U1xohUMWZA3HrswpFOdbzKyOEzTVwvglJWPNhyiQGg1wsOTYZhoMFhn/7FZE1aCPXy5r omvA1wmdc6yekfolfl9cR/yAEFFqhTU7vCPGGduR/4a2Az7tZg1CZaIoobdMdVlH4yQo SnmQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :cc:to:subject:from:date:feedback-id:dkim-signature:dkim-signature; bh=ZDEaMGjAyUtEyp/oo01G3wTVNw0AXLOJqKr0ugk6K3A=; fh=CNmQGxicobSgJFj1oomVSsiBpwDiLleioSCGcbaajNM=; b=ouWhx1BSXab/1tik8AaCNKRavIhq8/45bj7imrydu/L0X59bvWaaOryMuqVRcxyE2f gmFY7h8xn+lgu5kX+7vhBcUqhqxN9z3sAEx2eQIUWeG9BSYWOcA+TF5jAug4qG9J44nV TU4xqNvhidlZhhs7HNCS0XXPSRagdoOT0vZk1GrkZOagGRffZd4mltlraSM76gYJfjF+ eLhZVp0teUl6QFbqY1LnlXwHwLZuo8nKE+rIbeNDBeaT4x9G04pD87iqzaGyfBbLl4O6 pykFFdrXUb8WKv5ui16fwJfXA+7IVftOD2yL8ae8lq8Y+ay3W1UPJTxzhtK/YkupyuDI VeMg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@lyndeno.ca header.s=fm3 header.b=ftyHEgjD; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RlcvAH0K; arc=pass (i=1 spf=pass spfdomain=lyndeno.ca dkim=pass dkdomain=lyndeno.ca dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=lyndeno.ca); spf=pass (google.com: domain of linux-kernel+bounces-201706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lyndeno.ca Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2c2806d2aadsi365507a91.148.2024.06.04.19.48.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 19:48:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-201706-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=@lyndeno.ca header.s=fm3 header.b=ftyHEgjD; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=RlcvAH0K; arc=pass (i=1 spf=pass spfdomain=lyndeno.ca dkim=pass dkdomain=lyndeno.ca dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=lyndeno.ca); spf=pass (google.com: domain of linux-kernel+bounces-201706-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-201706-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lyndeno.ca 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 049D7B220F6 for ; Wed, 5 Jun 2024 02:46:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9534A5FB9A; Wed, 5 Jun 2024 02:46:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lyndeno.ca header.i=@lyndeno.ca header.b="ftyHEgjD"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="RlcvAH0K" Received: from wfhigh8-smtp.messagingengine.com (wfhigh8-smtp.messagingengine.com [64.147.123.159]) (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 C6FD910E5; Wed, 5 Jun 2024 02:46:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.159 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717555604; cv=none; b=PllEjRk3EUzK4aKaH0zlJ/M10nTjxkBNzStoUD4SQXsO2sTp3WSBdOQPCpsJcEs0+J4li0Jfc1l3GQvwf7ym9HFF6RbvdAZCgWl1zzxh3lwUoeYp1FM/5FeWaP5La0p0sJEWfW+2t5exWYGnVuRnY40MmEc7ZvhwR5hovuM42Ps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717555604; c=relaxed/simple; bh=mx5oQQDIpZKnQTteAnPD38LpR3Tu7KLeNebCCfqid4s=; h=Date:From:Subject:To:Cc:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=b2WzpIEUBM0HHsi0Plo4y+Ep02IvcFgRHw1qJ/Dtu4w2KmYOTgJUsOb0FdIqXlg3oYUWGXyCOm+NAhXHuB9oz95G31bCPpvB48mJkRWWSkAxMdDOZnxIOzB3jltghYY81II01nEdr/aWjo/oDDzOoCvSr0VYSJMm8GGxMFpcFrY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lyndeno.ca; spf=pass smtp.mailfrom=lyndeno.ca; dkim=pass (2048-bit key) header.d=lyndeno.ca header.i=@lyndeno.ca header.b=ftyHEgjD; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=RlcvAH0K; arc=none smtp.client-ip=64.147.123.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lyndeno.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lyndeno.ca Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 90CBA18000BD; Tue, 4 Jun 2024 22:46:40 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Tue, 04 Jun 2024 22:46:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lyndeno.ca; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1717555600; x=1717642000; bh=ZDEaMGjAyUtEyp/oo01G3wTVNw0AXLOJqKr0ugk6K3A=; b= ftyHEgjD2ZiPR2W+LuW6uyhoN3ih1KNKq6KeCs6ihbsXP0oouj1OUqjPsahRUghC ACD7jYDy7/J7N7xXCE06aQLQSPWEesfXroPJE1PAgxBSVxxcAP8sWG/vIdqCvXnL y1rVzkXAS2JW2a+SnX0QBAysZ2eJOFu8qFJhLi2qYVsjRUIpYxyNewRPms+EdGT4 Z6d8Mpgj23i6yYIJ9Bel8I0hq5+4Jiy4bl9otmyqiJZxm8gtJqWSglfbxmjy0M0g P5TKXObJS8C3wYCz8kG3qde9WZlSiycXQ/JMyVqTEXA4AiipZNa25UNCu0LOYyPn ILDZienr3E5mqfjuVvUWeA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1717555600; x= 1717642000; bh=ZDEaMGjAyUtEyp/oo01G3wTVNw0AXLOJqKr0ugk6K3A=; b=R lcvAH0K17eyIFiMyTHoJFTwKxG2/zhmnBJ10Ztax4uSwPzG9vFceqk+PYEdpJsJp tsKKY2tjPM+4apt22QNULJHUsm9wry5Q0edJKsktDCVbdkPYVMt0D5NTNDPqgW3k czyMIjKISqbRDqnrJO4Wgfh1LUrCxx0FD5cdIl7nCCs7X4CrYxTlWG1uiVsSI3rY Cs2vp+vWJ7V/j38lIclY85cKoMuiXcNxKjiDQ7r1jwpCr9CXXECDpRRgPzFg/pBN KPGn/s7LbmmMFOE1BtlBImmKnndYxyoP9jMBN3x6ByB8vE7XMJFqhYcfWvc7G+XZ ABzJWn881+pMNRA7kWl7A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdelhedgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhuffvvefkjghfofggtgfgsehtqhertdertddunecuhfhrohhmpefnhihn ughonhcuufgrnhgthhgvuceolhhsrghntghhvgeslhihnhguvghnohdrtggrqeenucggtf frrghtthgvrhhnpedtvdefvdetfeeggeejgeejvdevteejvdehhedtueeugfelhfeuieff ieehffetheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehlshgrnhgthhgvsehlhihnuggvnhhordgtrg X-ME-Proxy: Feedback-ID: i1719461a:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 Jun 2024 22:46:37 -0400 (EDT) Date: Tue, 04 Jun 2024 20:46:29 -0600 From: Lyndon Sanche Subject: Re: [PATCH] platform/x86: dell-pc: avoid double free and invalid unregistration To: Thomas =?iso-8859-1?q?Wei=DFschuh?= Cc: Hans de Goede , Ilpo =?iso-8859-1?q?J=E4rvinen?= , platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org Message-Id: In-Reply-To: <20240604-dell-pc-double-free-v1-1-6d81255b2a44@weissschuh.net> References: <20240604-dell-pc-double-free-v1-1-6d81255b2a44@weissschuh.net> X-Mailer: geary/46.0 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=iso-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable On Tue, Jun 4 2024 at 11:41:24 PM +02:00:00, Thomas Wei=DFschuh=20 wrote: > If platform_profile_register() fails it does kfree(thermal_handler)=20 > and > leaves the pointer value around. > Any call to thermal_cleanup() will try to kfree(thermal_handler)=20 > again. > This will happen right away in dell_init(). > In addition, platform_profile_remove() will be called although no > profile is registered. >=20 > NULL out the thermal_handler, so thermal_cleanup() avoids the double=20 > free. >=20 > Fixes: 996ad4129810 ("platform/x86: dell-pc: Implement=20 > platform_profile") > Signed-off-by: Thomas Wei=DFschuh > --- > Currently the call to thermal_cleanup() in dell_init() is completely > unnecessary. But I guess more functionality will be handled by the > driver and then this structure makes sense. >=20 > This is untested. > --- > drivers/platform/x86/dell/dell-pc.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/platform/x86/dell/dell-pc.c=20 > b/drivers/platform/x86/dell/dell-pc.c > index dfe09c463d03..972385ca1990 100644 > --- a/drivers/platform/x86/dell/dell-pc.c > +++ b/drivers/platform/x86/dell/dell-pc.c > @@ -261,8 +261,10 @@ static int thermal_init(void) >=20 > /* Clean up if failed */ > ret =3D platform_profile_register(thermal_handler); > - if (ret) > + if (ret) { > kfree(thermal_handler); > + thermal_handler =3D NULL; > + } >=20 > return ret; > } >=20 > --- > base-commit: 0da7a954480cc99978e3570c991e3779e56fc736 > change-id: 20240604-dell-pc-double-free-e8cf2aa9b2fb >=20 > Best regards, > -- > Thomas Wei=DFschuh Thank you for this patch. I was able to apply your patch and compile=20 successfully. I have not had a chance to try it on my hardware. I agree with the change, and it looks good to me. Thanks, Reviewed-by: Lyndon Sanche