From mboxrd@z Thu Jan 1 00:00:00 1970 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 2AA902F50; Mon, 30 Dec 2024 09:30:56 +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=1735551057; cv=none; b=M+iOn2AF6gD0DMPNhFp+5dAUDLLlZG7NaJPRTl6iB9WNsf5QYjNbRi7jSBj/CI1FzaeNBGTyUeQ3qL1Wr6ivdMJujuoAYbJ1u1PI9yr9pQHxhRdfBAnv8dcUv/ARuOE/lkwloK5y+pwQjV4fMnvMvNznX736uGf4z3Bqo412q44= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735551057; c=relaxed/simple; bh=OIUGQo/iIZMOB5N1vqzsOTaqkLjkGwgB8YS8iwbc2v0=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=u1mJwAChxAdEsZaxhNreSPH9J/mHhPlWNOh04sWt3gsG+hdDZOhkn4YOtmiEkezDBBZKRLkaUjZOj31xMGcYP09TMpRKeU7i4wCA/2TGY0eg7xH9FSIvSaCPlpyh2REybSAM5QE5olOLhlxt+iJb2Dzvlp+vrteI6sIxlDtvr7E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qckX+al/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="qckX+al/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E15BC4CED4; Mon, 30 Dec 2024 09:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1735551056; bh=OIUGQo/iIZMOB5N1vqzsOTaqkLjkGwgB8YS8iwbc2v0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=qckX+al/1vXglOD9P9vSAmfYmA19uYRolQf0JXidvL5u+I4or77p1FuPQjE74xMpH dCW3SbBOqjDb5Bn0Cfjn03NI4bLOC3UjHplyHO20287zKjnZQNXcVK7lVDOFUJt2lZ k4qI9aYak73bUKa+UUfznGAPCuDghFIw56b+NZOtNONsoeoQgFias5F8YWdqta4uza nywB1elkCyw52nK8pchAETGcVsVbsu1g+UVeeLtsw3lz8RiirlEiuruYqXVpC+EYZC 5Lu9tq62ZJugQNxFw3scsFyqC6tu6s6dmLs2DcKtWSt8yufDWe7PVvk3M5hJtp9GJA za7ko0aObsx6A== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tSC6w-007mVR-0P; Mon, 30 Dec 2024 09:30:54 +0000 Date: Mon, 30 Dec 2024 09:30:53 +0000 Message-ID: <86ikr1plf6.wl-maz@kernel.org> From: Marc Zyngier To: Charles Han Cc: , , , , , , , , Subject: Re: [PATCH] cpufreq: apple-soc: Fix possible null-ptr-deref for cpufreq_cpu_get_raw() In-Reply-To: <20241230035714.72780-1-hanchunchao@inspur.com> References: <20241230035714.72780-1-hanchunchao@inspur.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.4 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: hanchunchao@inspur.com, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, rafael@kernel.org, viresh.kumar@linaro.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false On Mon, 30 Dec 2024 03:57:14 +0000, Charles Han wrote: > > cpufreq_cpu_get_raw() may return NULL if the cpu is not in > policy->cpus cpu mask and it will cause null pointer dereference. > But this returned value in apple_soc_cpufreq_get_rate() is not > checked. Add NULL check in apple_soc_cpufreq_get_rate(), to handle > kernel NULL pointer dereference error. The only way I can see a CPU not having an assigned policy is when the DT is incomplete. And even then, reaching this code path doesn't look obvious to me. Can you describe how you get into this situation? Thanks, M. -- Without deviation from the norm, progress is not possible.