Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2363379lqp; Sun, 24 Mar 2024 15:54:03 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVP2u9czRIxCgEW/mgpn03kisJClNIs7/B5q/oCfE3mBRqfkYfz3tFFb8YdVdSVEnYGhJ2Lc+r/BV+y9saPqgtHJfaIz7/tTzFi9fq3Zw== X-Google-Smtp-Source: AGHT+IGH8+faf3nINMISbM8D31JFCofYSpCDACikDcFwXy6AJ1qUEtGrwJewCEUp1+fUQu8NM7Kb X-Received: by 2002:a17:906:a093:b0:a46:be0b:eeca with SMTP id q19-20020a170906a09300b00a46be0beecamr3639084ejy.62.1711320843407; Sun, 24 Mar 2024 15:54:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711320843; cv=pass; d=google.com; s=arc-20160816; b=FdORDEQmztp0Fo5eLAKGMIVHa2iYytFmMq7q1vVAmJhDmLfVePYHqU+8BkrtBe9jJk yOvPhP5kaFcEN3lghPCXJ0xXs5y4yz70922AnRoHfONjXEoLeSx1GnRcepdUJoVfokk0 WoFCAJ8A0H0bS4IEPLBK5mfpvrgGnPlL8cA8QAXs/IZEcRqNGkAawUnL3dAJGyIF0aBK UVfKk2c8QQCMXKNhIvfmbZWDsxXQu2SoFbdF3JJ/3h7j9aZT8YPOVrqS3vGDtdvLZ5Ea yQqw74Asawuj/zvwNfsphi5ldBStPZEnSPqH29gaAnFzyPdbxv9TDOi3XnH/UEIg0EQ2 WYIA== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=n0WjlOV9DAR4QsQNQowS8dpXo5Ysq90wOFtF8OjaEBM=; fh=JDdZwptYyzR19a+fdDz+XVwNaPjNuJlfw1ELHRg6nHc=; b=k7XbTDM2JgV+xKlRb3rkg3yyg2C71qb39pS97be6TsdlaWZSGoDwusoJ229s/wSP5J 6lm5cjsS5nkaxGIbUrRuobAqHUIgBGm13WjT/0soI5JoiqU/ABZjbfEiTKnHYoUl/vlq lGOv0lfxqSyhdA/d7psp+n4eTXEj+Zgw9qqVUVfwAI6URW38jp5W9oLsEiOD8bdOQIS6 Hk4S5+q27OOJxX1buJMh2lJzP81xqjIDN4QRZvx3uwqGxagsU6dzT4rwp5oBrtoNDYGt +ynJdxfTWVdpcDv5pHHOW1697zkgBV/EHtJdfYxhMcpZsc5n1aUy5xSkvC6hGBf5rLdg wW3Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JXJB8BWJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d10-20020a17090648ca00b00a4663640f9bsi2023022ejt.914.2024.03.24.15.54.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 15:54:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JXJB8BWJ; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112966-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112966-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0F0731F216AF for ; Sun, 24 Mar 2024 22:54:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8E461292D8; Sun, 24 Mar 2024 22:36:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JXJB8BWJ" 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 BDB1312882C; Sun, 24 Mar 2024 22:36:17 +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=1711319777; cv=none; b=q2RJmtprufQAq3p+Z758PXV/IF0Ra4n80Qrf171ZqVTn/bqMiDWcCWwtr6D50nAcLneahP5Rne4JCOxPFl/Mdmx2hsWP/61i+ALBqLr8PDMx/opgZ3R7+A47ieu1Yumk7Fca6Y/LqmL7k0CqHE1+10pxhxzxzOVYShb8pqSaOvQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319777; c=relaxed/simple; bh=RiNJz9zlSFXEx8zYJSB1a4ND7aEOOQrZQdR/XEnpxN4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B+3m2zueTwVTSpJWkDtZAjaEFgO9l9Bb2FiRww3AxcrD7nuT00YOjR+WTzLXDvnhkQ3UvEkpUn5nuudpJ1KO1IfKdQdmW3ve0B7/P0q573Gq4idq+PrYj/Gi22VpZBylgF1Lfc5oCxNXvPwLNRTJHt6JEAFXKTlIZR6hlXBW/cg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JXJB8BWJ; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE9DDC433C7; Sun, 24 Mar 2024 22:36:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319777; bh=RiNJz9zlSFXEx8zYJSB1a4ND7aEOOQrZQdR/XEnpxN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JXJB8BWJadwdBs+vSLJdprGNC94d8AaJqVrNUp7q0YWULHfRJko7ii7qftWICISh2 zfsuApO1k4V8IBAP5QtZeKr+l/jc2pbHvmAdboUqM9axfNdl/hG+SiFXw3Rnm+AmTT APFDBN6yS06fVzvn1h2gP5sqfck1aDffcoBWq75DpynQruk3ny0gWbFl2XGKtWkW4N WKzS6TflnJjaYlhWTIaXcgbH8Petsog92UWTEUASTCy/SG/rUkxUPemIoO+XoQCYT/ hSlVQ4QeiaNH0IrIE9l3I6ug8eXnMyPXJePnhXznlhnqBoQCQnZ/aDYoxyJMoNyMFG Ow4qSXuLRk8GA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anastasia Belova , Viresh Kumar , Sasha Levin Subject: [PATCH 6.8 079/715] cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value Date: Sun, 24 Mar 2024 18:24:18 -0400 Message-ID: <20240324223455.1342824-80-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Anastasia Belova [ Upstream commit f661017e6d326ee187db24194cabb013d81bc2a6 ] 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 Signed-off-by: Viresh Kumar Signed-off-by: Sasha Levin --- 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 35fb3a559ea97..1a1857b0a6f48 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); -- 2.43.0