From patchwork Wed Jan 17 07:12:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 188704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:42cf:b0:101:a8e8:374 with SMTP id q15csp741413dye; Tue, 16 Jan 2024 23:13:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IGxSbt2CGswfarBvoSs5EpH5cfiy9GeLeUV1TYtOloSuElDE9Gi79z5MYmqKDBsnCJekhWG X-Received: by 2002:a05:6a00:e84:b0:6db:76b3:29c3 with SMTP id bo4-20020a056a000e8400b006db76b329c3mr6393222pfb.3.1705475608431; Tue, 16 Jan 2024 23:13:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705475608; cv=pass; d=google.com; s=arc-20160816; b=p/XpUI4KxwvFgH5T0C9F+J38lPBJVeVrF3cELrK304+xLHyLV72c/osXdUlSWU22ZE PFajK6I4Ipnfy1B7EgjDG1gNNbmgmuxhBXmHlvdBrdi9luZB9Fi3bYzCaLWkQKznTApT S5v63mh9GC+IPrIyVUH21HRlMMJNJmz9vnAoHqLvrEgcM38xvQvj35RzCB8xeNsQZrlq B1bIcNZkZiNmeRv/PtZ5AA/cHt23bzTcWbksZbQAJPHpZJvOjhPZnSHZ5eOBRsODUl/C 5OTwgquDOpffzialLWnxhFig+vPs1hH8Wa7/zFoewUh9+ycjA0y/D0v750ZME7Hb0mdJ HCbQ== 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:message-id:date:subject:cc:to :from; bh=CJQ64ujng0KJ4KJtdfMf846dTRikhUQKYVpwHlZz9y4=; fh=5p01H8v6zH+vD5bPumEXFEdiDn1cFGV0FPuLwH94Y/c=; b=wPL1bF1v7J4kvZM5A5MFbWRqbJ64vkPTMa5GvSKaZE7GG5lV8wbLJag5FtvdqlxbUa qp109sJLNIkpBP6REx27VZfKNbyitJymeBHEu8zTL+TCGiHjlzjR6/aBSkKl8kS6ZfU0 0o0Jv0NCNwwebrsQ49EpawVPrlCMoGLyMpW3iTBsWJ3ui72bK9jqdH1354dMaDeaaBdh 4VybBjTYDsql3DSNvY0XbR0y8RtJ3BKLp46ZTeR/XDKOAdAJ8hFuvc8f1/31ODdyMVty g9YfRg9Jj1E/nEnBgm97m3zDSNlF+B4BTxMwbqntTuhtwseJKmZ2EaHCkAtdEAdls2aN qhSA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-28587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28587-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id b190-20020a6334c7000000b005ce008218b6si12793915pga.841.2024.01.16.23.13.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 23:13:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-28587-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28587-ouuuleilei=gmail.com@vger.kernel.org" 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 3C6EEB23E71 for ; Wed, 17 Jan 2024 07:13:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0363ABA50; Wed, 17 Jan 2024 07:13:11 +0000 (UTC) Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) (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 00D025CB0; Wed, 17 Jan 2024 07:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.74.38.119 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705475589; cv=none; b=D/b/HyI5Za18w6nNW2cRst7gnBkkd6ukBHbvnwMYxnbBZbbt4R2u6aMdrGNUnAU+Z+cmSpK7CtHWrzPnU0MCk4g2hhUR8k610mQYZDgweK9ik+S9qAiuHrS5atCMuqjdSIf8WVA817jJDsfDNSiEk2tn8oWdeTSzIBU2fnAAGyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705475589; c=relaxed/simple; bh=VOPRzbPoK6eKabzYFOueNX9M9qUZqA8gbMPhJ2kva4Q=; h=Received:Received:Received:X-Virus-Scanned:Received:Received:From: To:Cc:Subject:Date:Message-Id:X-Mailer:MIME-Version: Content-Transfer-Encoding; b=N2dtafzipByPov7+iBVpR+a7dqJq6sINxjzQ2hhJUEawBalBS2I4kPxNsx56NN69dQ6WDDqAYIxOMnZBV/2EXbgv3UzLYnzTM+Xnxh5moGufq9Byv5cttkuAGdIE60tIlyIB5A0QS7XOSf/F3gnH6kWoLzeoL0SeB8OryAyChw8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; arc=none smtp.client-ip=217.74.38.119 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 506861867522; Wed, 17 Jan 2024 10:13:01 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id DHjOdtHDzmxA; Wed, 17 Jan 2024 10:13:01 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 0096D1866B46; Wed, 17 Jan 2024 10:13:01 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z5YQWJPYpUoM; Wed, 17 Jan 2024 10:13:00 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [62.217.185.39]) by mail.astralinux.ru (Postfix) with ESMTPSA id ED2A91863E43; Wed, 17 Jan 2024 10:12:59 +0300 (MSK) From: Anastasia Belova To: Markus Mayer Cc: Anastasia Belova , Broadcom internal kernel review list , "Rafael J. Wysocki" , Viresh Kumar , Florian Fainelli , linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value Date: Wed, 17 Jan 2024 10:12:20 +0300 Message-Id: <20240117071220.26855-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788320791521225196 X-GMAIL-MSGID: 1788320791521225196 cpufreq_cpu_get may return NULL. To avoid NULL-dereference check it and return 0 in case of error. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: de322e085995 ("cpufreq: brcmstb-avs-cpufreq: AVS CPUfreq driver for Broadcom STB SoCs") Signed-off-by: Anastasia Belova --- drivers/cpufreq/brcmstb-avs-cpufreq.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index 35fb3a559ea9..1a1857b0a6f4 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -481,6 +481,8 @@ static bool brcm_avs_is_firmware_loaded(struct private_data *priv) static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + if (!policy) + return 0; struct private_data *priv = policy->driver_data; cpufreq_cpu_put(policy);