From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EC501E77194 for ; Mon, 30 Dec 2024 09:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Rs0JoPwnODSC/gVU3sZsdeSee/nnHapoqHtEl5UCNm0=; b=zIbBgFCMWJNpP3FM5pqbKZgZc3 kSu/0/Gy1dNQchesSuwj4KgkXLqgenTxFRnPVGqvMO8k/UuvqX2FJr7aLaNLvcpZPJzP8a9iUvisL BRRzHXTt8WDgZk8TqlUDgYOfFTy5FmoVi3z+kUjrUmIZyFfaCiSs41iUzTcqrtNFDtd8ghhLn3FKE f5ncDBc9WG2psNxtpuCxymqWwd8ypaSakns6zA26xHuGpXpSNEmxiOcNyDuUI3ZyPLm5817+PTyrr nAinJt2kK7cAdpArNC+GNPSDCGZO1FrA7IBG8nuCfwlGnLwATQ2/Uzqv3ZXwV0+RO5d3bguziTGHq QOEF/a/Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tSC9x-00000004wrM-0PP2; Mon, 30 Dec 2024 09:34:01 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tSC70-00000004wRA-0Ahy for linux-arm-kernel@lists.infradead.org; Mon, 30 Dec 2024 09:30:59 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 64FBAA40B8F; Mon, 30 Dec 2024 09:29:07 +0000 (UTC) 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) 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241230_013058_143058_754EBD08 X-CRM114-Status: GOOD ( 12.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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.