From patchwork Tue Sep 10 01:40:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koichiro Den X-Patchwork-Id: 1982881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X2md20MClz1y1v for ; Tue, 10 Sep 2024 11:41:09 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1snpsG-0007Fl-RW; Tue, 10 Sep 2024 01:40:56 +0000 Received: from smtp-relay-internal-0.internal ([10.131.114.225] helo=smtp-relay-internal-0.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1snpsE-0007FK-KB for kernel-team@lists.ubuntu.com; Tue, 10 Sep 2024 01:40:54 +0000 Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 6854C3F5B8 for ; Tue, 10 Sep 2024 01:40:53 +0000 (UTC) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-205516d992eso2377895ad.3 for ; Mon, 09 Sep 2024 18:40:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725932452; x=1726537252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yq/mN/BvmY+3YtoeL8pHYUGmK74W0Hk/ShmI8SHgMr4=; b=BO6F9HWFX1sMD8ZjcqUdgImLVaY2kV1dvprkWzSMbm4grvTfJefKZUjqG2yHErv/Mc /tG9v38B3w7CTB6PjkfLkt3Sc0wATcbWbN0Znr8AOYAz++eaZ7yC+XoUO5EMiFsDDpFG GOhhdTlMb2eDV0JdmLHB2zgKpSF+ngy3YhZQbDY+LDEVhNzyIzDzgtAaeup31LBbED1g vZS/KMUGDxtqcBRg8gxCXhjZbyiXkBenZkyzsq70xOhGS2iLpbdznjpR49hTwvfbzpeM yuye9/LbPif0+rMLJgbEahhtkrTIKsZKu8Aw9H3b/JW/popjoakq0sUnX8ZKD3EPWpJ0 TExQ== X-Gm-Message-State: AOJu0YwvdkGnpLLTHJCMd230v/El44dEdlm1TDOtEV3OijlZMoPZyJHi osACZbipsfIBsa9cQpIhYzAogOH5QaAUfyXxd2BUlPu4v6pI0GgBkDZuglYvchBERGmrQFqatHR P20VxI/vW96434jmUfFDFsh217bctNooSQS/NQFUAbaj2AkEKMExZgt2bXvcR7XN4hFWOu+f1yh i2oiQYwrbvlg== X-Received: by 2002:a17:903:18b:b0:207:3a5d:69b7 with SMTP id d9443c01a7336-2073a5d6b19mr35496445ad.15.1725932451861; Mon, 09 Sep 2024 18:40:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElWirrFzG9oSOng42Q6V4zg/oDsA3Zp1fTtO7p8U7xuledLUZfAlDRPHJ5Hr1TTAPF7kNfUQ== X-Received: by 2002:a17:903:18b:b0:207:3a5d:69b7 with SMTP id d9443c01a7336-2073a5d6b19mr35496075ad.15.1725932451347; Mon, 09 Sep 2024 18:40:51 -0700 (PDT) Received: from localhost.localdomain ([240f:74:7be:1:959:86f5:52c1:2a4c]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20710ee1ecesm39252415ad.181.2024.09.09.18.40.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 18:40:51 -0700 (PDT) From: Koichiro Den To: kernel-team@lists.ubuntu.com Subject: [SRU][F][PATCH 1/2] cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value Date: Tue, 10 Sep 2024 10:40:22 +0900 Message-ID: <20240910014027.1051871-2-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240910014027.1051871-1-koichiro.den@canonical.com> References: <20240910014027.1051871-1-koichiro.den@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Anastasia Belova 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 (cherry picked from f661017e6d326ee187db24194cabb013d81bc2a6) CVE-2024-27051 Signed-off-by: Koichiro Den --- 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 541486217984..1302e1900dcb 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -457,6 +457,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; return brcm_avs_get_frequency(priv->base);