Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp227889rdb; Tue, 16 Jan 2024 23:13:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IHPDsnRgFCoa5ESKIeZTzlXJdPRGz3gu4ucXZDq4OQB6+5cJBGQgneuOC1Rwp9b5NU8Kj4v X-Received: by 2002:a05:622a:130d:b0:429:fdb2:6279 with SMTP id v13-20020a05622a130d00b00429fdb26279mr3544723qtk.88.1705475597032; Tue, 16 Jan 2024 23:13:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705475597; cv=pass; d=google.com; s=arc-20160816; b=dxf/rywakuSxyw6NPJotl0/B6bSdeB4JKIMixtWNTrhLFjNFGy7q1ZUZ0Kq3RudoZg Qhnn/ERPgOk9kMe8Jqy7vQjI7LLT9xgm+GtnMLTM+GhvrJ8gfihHHK2nBUH+3apZ8Wdp OaARkNcPyhkvd1/A3cPMcfvren0Xcgd2L4kqxOU31KezyFXouEwXthUbkQr8kNkbjNBd 7GJGZoT3ev5ylW7vhnlzwRSln3111GfMc19h3Nfb1W7Q/iJGMHAFh+U4g7SH7KhjAR/k iPFT7eP8GUPIKSO7AUZZKbsrpOrLI+F4qQdkESlIroFJsNxe7U9v/W8oK/znC3/nPFSu B5Ow== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28587-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id w4-20020a05622a134400b00429ff99bec4si3232332qtk.299.2024.01.16.23.13.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 23:13:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-28587-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-28587-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-28587-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id C52011C2375A for ; Wed, 17 Jan 2024 07:13:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F1FBE9463; Wed, 17 Jan 2024 07:13:09 +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 Content-Transfer-Encoding: quoted-printable 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 fo= r 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/brcm= stb-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 privat= e_data *priv) static unsigned int brcm_avs_cpufreq_get(unsigned int cpu) { struct cpufreq_policy *policy =3D cpufreq_cpu_get(cpu); + if (!policy) + return 0; struct private_data *priv =3D policy->driver_data; =20 cpufreq_cpu_put(policy); --=20 2.30.2