Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp890226lqj; Mon, 3 Jun 2024 04:16:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVt3vvUrg6BWB93SSSaxbVNRMAP5DItl8xwyvnCoQ/uJeWMUbxmw4ApL1sNsYSuZUc35h/Tsl5szQrw/6zF/9zutLMLVAmlsHX0gnFduw== X-Google-Smtp-Source: AGHT+IGwbTUy2axSwpVrledLHBw6ahb3OLa6EYtju7YrdN1csSV5oSPnRYMVsDH26Hxg1xZZsnQz X-Received: by 2002:a17:907:3da0:b0:a68:ea80:f54b with SMTP id a640c23a62f3a-a68ea80f721mr317371266b.18.1717413389414; Mon, 03 Jun 2024 04:16:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717413389; cv=pass; d=google.com; s=arc-20160816; b=ULrlDbFXpV/3c0oQiYZ6HH3CeaKqy0hF434wvipeire7S3m8F47nTnQb+64QQKBu5x xSIiYQdvGr20kJqOLLUa74vZbjGMc7ihgOxlOYmopAU12nAAsg3jaqDC39gYSF69zsa5 sdQuPDekoib7psNPqkltt9MAZqcv5+0Swni5tyNnxvULgSUdiW1Ax63evBYWcbFUhnD7 0LxFIDMYViILFGrVmX+1mAVC0IWgRCeeHDZOqhyIz0HuSTs/A4RGM3xJv62IaMt/3wOA TLBRFSife+9VDfouKBLWh+fc1Ld523975TMk+xeiNEsrz/wyzO025129Kj6TsdQAXuVu SAdw== 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=uHShAFR+W2J6udnVZfvxRZQ7AE6OuK5Sg0FiEiCeXv4=; fh=S8dsxVEfEcyezWic4y7SmfML1uuTkb7Fhs22vE65kgQ=; b=d7vqlxTW+SYkU9t+OqYAVYB8eTqAZ2JGzZOse0j2VWRwFr9V6xfi6/Ylkkn8ES4bR4 nz3LBGflHN7yA/PjGyRuk5tL2XsBSG+0OGXGAJJddwdsNWp/0uqeAO6x45qnL/FqZB+H NgC8gf4DqSYeLGNFDNTYxCJY1m6D9BI/JCpe715ubo2una3q/kuE2O6n82/PytqEJPpV 88LIkDZMLnHlZv4c97+4k2THLJrjNmy9D3kcj7jjxp/jyQrDJRMc9Xh8vhnOtzYG8c0G Wot+Cdi+sH+HH1lrp56cJWOX0Qxkdr1mHYI0hr2mfVsufXVQORJwI/qm1g8lONJe6LSo sLkw==; dara=google.com 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-199028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199028-linux.lists.archive=gmail.com@vger.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 a640c23a62f3a-a682e24f011si360424366b.486.2024.06.03.04.16.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 04:16:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199028-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; arc=pass (i=1 spf=pass spfdomain=astralinux.ru); spf=pass (google.com: domain of linux-kernel+bounces-199028-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199028-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 16B501F24572 for ; Mon, 3 Jun 2024 11:16:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C0CF85290; Mon, 3 Jun 2024 11:15:19 +0000 (UTC) Received: from new-mail.astralinux.ru (new-mail.astralinux.ru [51.250.53.244]) (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 A0BBA84A51; Mon, 3 Jun 2024 11:15:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=51.250.53.244 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717413318; cv=none; b=Qp/3UwSp443PTzcc5UmPtdToILNJy6lKo6Brdxeq0otbDDm4AyrZwachw8x/VR4K6z9P03Fm1DoX9e7CBCvVGDyHYfFdv+2sSjaUuh8vci4nyLOjw01Fq7SiG4Renzgcc5BgusemLG9s7x9mkDUDSZWWYCTuGzGqJ1Nja7KFI/c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717413318; c=relaxed/simple; bh=f0yBKYMqtygn3cVibz3OF+CIlIM/Id+Akw/nJOBq5Es=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ERbFSz+Xj/xgdfWbYkJ1RVo9oiP9i2otyjXrePYjP+Z7VQs54EnEFakOUcn8YjSIli438gC0GGtdc23pB314lEAkLpLsJoHBRVthj9RfJhpz8RA+iVsN7e/D3MO52THkEol+XPT81jjnBJ3mdPDG7lb1QVjDKKammzkZhX8zd7k= 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=51.250.53.244 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 rbta-msk-lt-106062.astralinux.ru (unknown [10.177.20.58]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4Vt9vK2f0bzlW00; Mon, 3 Jun 2024 14:08:29 +0300 (MSK) From: Anastasia Belova To: Huang Rui Cc: Anastasia Belova , "Gautham R. Shenoy" , Mario Limonciello , Perry Yuan , "Rafael J. Wysocki" , Viresh Kumar , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] cpufreq: amd-pstate: add check for cpufreq_cpu_get's return value Date: Mon, 3 Jun 2024 14:07:41 +0300 Message-Id: <20240603110741.24818-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: 8bit X-DrWeb-SpamScore: -100 X-DrWeb-SpamState: legit X-DrWeb-SpamDetail: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehuddgtddvucetufdoteggodetrfcurfhrohhfihhlvgemucfftfghgfeunecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkffoggfgsedtkeertdertddtnecuhfhrohhmpeetnhgrshhtrghsihgruceuvghlohhvrgcuoegrsggvlhhovhgrsegrshhtrhgrlhhinhhugidrrhhuqeenucggtffrrghtthgvrhhnpeffvddvueehvedvgfeivdeuvdduteeulefgfeehieffgfehtedutdfgveefvdeiheenucffohhmrghinheplhhinhhugihtvghsthhinhhgrdhorhhgnecukfhppedutddrudejjedrvddtrdehkeenucfrrghrrghmpehhvghloheprhgsthgrqdhmshhkqdhlthdquddtiedtiedvrdgrshhtrhgrlhhinhhugidrrhhupdhinhgvthepuddtrddujeejrddvtddrheekmeegtdejtdegpdhmrghilhhfrhhomheprggsvghlohhvrgesrghsthhrrghlihhnuhigrdhruhdpnhgspghrtghpthhtohepuddtpdhrtghpthhtoheprhgrhidrhhhurghnghesrghmugdrtghomhdprhgtphhtthhopegrsggvlhhovhgrsegrshhtrhgrlhhinhhugidrrhhupdhrtghpthhtohepghgruhhthhgrmhdrshhhvghnohihsegrmhgurdgtohhmpdhrtghpthhtohepmhgrrhhiohdrlhhimhhonhgtihgvlhhlohesrghmugdrtghomhdprhgtphhtthhopehpvghrrhihrdihuhgrnhesrg hmugdrtghomhdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvhhirhgvshhhrdhkuhhmrghrsehlihhnrghrohdrohhrghdprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhigqdhkvghrnhgvlhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlvhgtqdhprhhojhgvtghtsehlihhnuhigthgvshhtihhnghdrohhrgh X-DrWeb-SpamVersion: Vade Retro 01.423.251#02 AS+AV+AP Profile: DRWEB; Bailout: 300 X-AntiVirus: Checked by Dr.Web [MailD: 11.1.19.2307031128, SE: 11.1.12.2210241838, Core engine: 7.00.65.05230, Virus records: 12717933, Updated: 2024-Jun-03 09:24:46 UTC] cpufreq_cpu_get may return NULL. To avoid NULL-dereference check it and return in case of error. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Anastasia Belova --- drivers/cpufreq/amd-pstate.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 1b7e82a0ad2e..672cb6c280a4 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -621,6 +621,8 @@ static void amd_pstate_adjust_perf(unsigned int cpu, unsigned long max_perf, min_perf, des_perf, cap_perf, lowest_nonlinear_perf, max_freq; struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + if (!policy) + return; struct amd_cpudata *cpudata = policy->driver_data; unsigned int target_freq; @@ -777,6 +779,8 @@ static void amd_pstate_init_prefcore(struct amd_cpudata *cpudata) static void amd_pstate_update_limits(unsigned int cpu) { struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); + if (!policy) + return; struct amd_cpudata *cpudata = policy->driver_data; u32 prev_high = 0, cur_high = 0; int ret; -- 2.30.2