From patchwork Wed Sep 29 04:42:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Holland X-Patchwork-Id: 12524605 X-Patchwork-Delegate: cw00.choi@samsung.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E44A1C4332F for ; Wed, 29 Sep 2021 04:42:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CE59961407 for ; Wed, 29 Sep 2021 04:42:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243907AbhI2Eoi (ORCPT ); Wed, 29 Sep 2021 00:44:38 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:50399 "EHLO new1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234322AbhI2Eoi (ORCPT ); Wed, 29 Sep 2021 00:44:38 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 487FC580DBB; Wed, 29 Sep 2021 00:42:57 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 29 Sep 2021 00:42:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sholland.org; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm3; bh=ALZ+89RMWvaZz rA1f7LpbYBKk681jYZFRU0J8EDdz70=; b=aHOjpZKk7ni97VKtrRLtFFZ1iwGIB TMsK+fc3B68/7XiuJEksS+ihr0aNky5WGq69mSCxkXvLLCfAEHvoYD8OG+xHwxxu MnoWI2lDuQSHi0vWwoiq75uDr4G2HHQcFl9wcIf4IV9QrTyiVQgaeBMiULjhZ+Cc LOxlecqpNeVqbj8F8ymmlm64uhnmLbv1r3XaC2r5IcGw2CZCpWP9LbPRQoWXZzXt KrTCBVNnl/NPhpjwR4j9iQ8Qp9BVmo4jNnvvtfCq5s1RL4zcs2KO0/qxb4IjJNxR Bq8zhihG8vEkwXzajg97ZE+uXz5Havo+pkcRuupzTKy+TU03wZyudCceQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=ALZ+89RMWvaZzrA1f7LpbYBKk681jYZFRU0J8EDdz70=; b=C6BDVr2i pB1eDRrcoLpIh7k9Ln4kEIWtdGCxsMLREz8kkBw9IOBwwzjWuJXpUrWKyzL7hkVK 0uth7rQKW8/O1Zh2/F3eleeVZbKje96cph8nA3T/VUMfi7E8j/zG+v8Y4t2m2PKF t/nnMRNxreTl6hga08MvCqUW3hN95YqsVJCNql5nWfw+F+W236Keao+e7aPZMkxj 68maWWp4wm3F6StaFq0NszG6CXV+KuyuRjQFLcriyTvwO0bzLWGlklMWSwhENFBP jy8vp1z2oHI56xlfNrkekGH9o3Qwvqv922xH+MvyWChFCFJELdyIP/SKbjwXvBHZ BLMaR2zvjOoZBQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrudekuddgkeegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefurghmuhgv lhcujfholhhlrghnugcuoehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhgqeenucggtf frrghtthgvrhhnpeduhfejfedvhffgfeehtefghfeiiefgfeehgfdvvdevfeegjeehjedv gfejheeuieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhroh hmpehsrghmuhgvlhesshhhohhllhgrnhgurdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 29 Sep 2021 00:42:56 -0400 (EDT) From: Samuel Holland To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi , Maxime Ripard , Chen-Yu Tsai , Jernej Skrabec , Rob Herring Cc: Michael Turquette , Stephen Boyd , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Samuel Holland Subject: [PATCH 01/10] PM / devfreq: strengthen check for freq_table Date: Tue, 28 Sep 2021 23:42:45 -0500 Message-Id: <20210929044254.38301-2-samuel@sholland.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210929044254.38301-1-samuel@sholland.org> References: <20210929044254.38301-1-samuel@sholland.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org Since commit ea572f816032 ("PM / devfreq: Change return type of devfreq_set_freq_table()"), all devfreq devices are expected to have a valid freq_table. The devfreq core unconditionally dereferences freq_table in the sysfs code and in get_freq_range(). Therefore, we need to ensure that freq_table is both non-null and non-empty (length is > 0). If either check fails, replace the table using set_freq_table() or return the error. Signed-off-by: Samuel Holland --- drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 28f3e0ba6cdd..7a8b022ba456 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -827,7 +827,7 @@ struct devfreq *devfreq_add_device(struct device *dev, goto err_dev; } - if (!devfreq->profile->max_state && !devfreq->profile->freq_table) { + if (!devfreq->profile->max_state || !devfreq->profile->freq_table) { mutex_unlock(&devfreq->lock); err = set_freq_table(devfreq); if (err < 0)