From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 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: platform-driver-x86@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