Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2572398lqp; Mon, 25 Mar 2024 03:06:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU+UsHUmo+W7qaXN4bhu/avX1aP8IYTdxiF7d6usHXeQNTFwPPsLxvBAIpx1CovuVnEWroXSVMC8y7hgRAU8JuvXgBfXDwoKjhKO6e6KQ== X-Google-Smtp-Source: AGHT+IGao0JBcKM+ytj9vpQ0dwfi2n1VdWPuxjUpZHU82ynCD1O0gSYezxIgWZgfdolwV9wX+41c X-Received: by 2002:a05:6a21:33a2:b0:1a3:b00b:229d with SMTP id yy34-20020a056a2133a200b001a3b00b229dmr6307542pzb.43.1711361173846; Mon, 25 Mar 2024 03:06:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361173; cv=pass; d=google.com; s=arc-20160816; b=ycyy8BfbRDmHuFWD073Rx/LltFg88SXuBp1C0h76bdX1JpCXIjUuJ6BqPfpE/e6htg SPAVetckM2/ydLh9jVEXNZKhIAhQz+GQuVLhHZlP4i88zEt73GOg3lP5HlOU2HLw9Vqk 1g4glSa6XCWJnWhvReumk1/+GLpLnQizDW1U6Yb6VO4cumh74sMHY/6wUTKS0PzT8BNi Ao+Q3zf1dlizOOhjzp2e+RKTNl8vvTfJvRuc7Td+n1DbyJ9JoHp9DXnxFSfAkX1oO05b 9TFNrxKP2+AJCT4eOrlytDS7kQ0UEJ9P6FZ4cVonFO0zOLn2mmeqQAO9kQ2rz7CGpLij BUmg== 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=r102JlJk3EAgK5Q3F1zJ4+HHs2o1nq4KZPujHGJ2E+Q=; fh=JDdZwptYyzR19a+fdDz+XVwNaPjNuJlfw1ELHRg6nHc=; b=PtUjCTu8DgT//Qh2p5WASo/0h69LyIJoVZIGfi/eXPUz/CvzRBU2Z/yMHXhhNid/Ne EZ37FFxGkjIIfywDbFI41jencGfNrrDJmtI4Y4jBxQUbSsu2C4raz/TFXcz09EDMNLPt cWtrJmj1OJnmeBa44r73RSe7h9FUL+ABDA1i+1jCVHWS7dQBK3KBmDUFayiPmufm9VEa 8P21fK/rC84SdCf9q8j65TEEDu6d07VgVGXkUROBBJn5ORmWp5UKfqLlB8PTV109nFq7 2Tha/zv6GC8JVC2sOC1g+oygHkxWzlNSpgnNc2lyCl+Fvq57yleE7uKaPZIb7A5aLtx2 Gs8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWQfivTn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115857-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id u9-20020a63ef09000000b005e270acf8f3si6933848pgh.748.2024.03.25.03.06.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:06:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=uWQfivTn; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115857-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115857-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id EC0DFB38EDA for ; Mon, 25 Mar 2024 09:34:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61DE837F7FF; Mon, 25 Mar 2024 03:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uWQfivTn" 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 05B8012EBDB; Sun, 24 Mar 2024 23:13:43 +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=1711322023; cv=none; b=o8IPhC70oAV+3+IZmGBqFh3s+JDaeXp+4lOxwuszf3HfgPGSQqgzgtJMcxf7+vplx8JveDbhvZVji7G/v9mWHuhS8JkcwU7vrWqPZDa5GZYo9SQfhgUNfaS0eakyhV1JttlDETWMT5zafeOUAbETvx0yA+IXGKz0PsbeaOHsuXU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322023; c=relaxed/simple; bh=3v2u52gHV9cGUvW7r3oyCpl4u5Lb7Ipc60LXIYLcw5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4LDdjhjLUpXMhO8APIZqOrFqyUIGu3ji8SRt3Lo1JQn27QSkqDYuLHrBOS3nKkdrNwlQ6D+Py73eWL83xUHqmaSvUqMwHBj0wyzrcfCSv0PNWeeWftxKmRKnC5boPtWswyiwOuJeNhw8jV7B41kwif/99GCZILkY2rXs93wLBw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uWQfivTn; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41D6FC433C7; Sun, 24 Mar 2024 23:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322022; bh=3v2u52gHV9cGUvW7r3oyCpl4u5Lb7Ipc60LXIYLcw5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uWQfivTnZOZxePbrVziu0p27r4rzY4dTM1sSJMs5+F5HvgyqnyUjC+gMxw4A5fefS arZz8ocYJ8SIe59/hgLbINN7tESbKrH9/xFS1Y1b0DTQOz9xGJUfooW7BS9Ee8wTXV g/tNqK6LuwaHN2dUe996Y4wcdw6zZBONPlYPVqj05MK3tmEASbXxGYDcMh8dLw+4bE uLGkZJ4pUNoc+u7ED0BGKacvX6nCQdDenMiV4C4phWyJY4u0ylJn1sydWtk+3qBhcH AvLyLgMZLg3Fvxdpi1VdzFsSL/zkx6bRZadPxtx+w5q4XnYrpZOFPyXCF4+7qo4o8Z 8uMvaAVeu/SAg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Anastasia Belova , Viresh Kumar , Sasha Levin Subject: [PATCH 6.1 095/451] cpufreq: brcmstb-avs-cpufreq: add check for cpufreq_cpu_get's return value Date: Sun, 24 Mar 2024 19:06:11 -0400 Message-ID: <20240324231207.1351418-96-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 f644c5e325fb2..38ec0fedb247f 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