From mboxrd@z Thu Jan 1 00:00:00 1970 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 73B952F7461; Tue, 12 Aug 2025 17:41:09 +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=1755020469; cv=none; b=Rwt+9RzBJSezf4VqiLDTkEfySD4OVwuLbnGZhJXaV5aULZzTNA0CH9V9hiihZ2QwoCT+AbCh4kdGCwR09KwP28FCJGPu9/wkrpBQxT9WIGd9tASg1E5OlY2HHZl9x4vobGq49g8+2NahuPcmI8761PWZAjZReBMeNece/AQuAGc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755020469; c=relaxed/simple; bh=CdXDwK+pGXmEBLuVE32bcG0TEchCBrINYZpM9UlUDTk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KAMckvna35q5QjnwKSZyqrOdEahM6SIG4409h8LeYo8QiL1VZa4UeM0CcvgTtHPuqIyo/LQuoyK2eO6dZ+viw7un/ft3toQiTLCBiDA1gu7nzVLN/b/8XE+Ex2cwCpnuEkK0OrKbTdwWX5SwsFu9rSgNKjbbmwpvrl++VX8/VNU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kCWyXMtA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kCWyXMtA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE278C4CEF0; Tue, 12 Aug 2025 17:41:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755020469; bh=CdXDwK+pGXmEBLuVE32bcG0TEchCBrINYZpM9UlUDTk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kCWyXMtAbsDDkw+VZW4pT/fbHP6wyoO3PNs7+YOf983cyBWsPZwmVpqCkOEEtvlWM dW0cv2LpL+WabmWBORyaare9AeDpSD6A22qviXCrW1So9JAZvOqtKMQlTun3CzHlkq gyP6ceRmicmXNUq0oXwYMslOoIo9xa3Y/ivc/48Q= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Lifeng Zheng , Chanwoo Choi , Sasha Levin Subject: [PATCH 6.1 088/253] PM / devfreq: Check governor before using governor->name Date: Tue, 12 Aug 2025 19:27:56 +0200 Message-ID: <20250812172952.480188813@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812172948.675299901@linuxfoundation.org> References: <20250812172948.675299901@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Lifeng Zheng [ Upstream commit bab7834c03820eb11269bc48f07c3800192460d2 ] Commit 96ffcdf239de ("PM / devfreq: Remove redundant governor_name from struct devfreq") removes governor_name and uses governor->name to replace it. But devfreq->governor may be NULL and directly using devfreq->governor->name may cause null pointer exception. Move the check of governor to before using governor->name. Fixes: 96ffcdf239de ("PM / devfreq: Remove redundant governor_name from struct devfreq") Signed-off-by: Lifeng Zheng Link: https://lore.kernel.org/lkml/20250421030020.3108405-5-zhenglifeng1@huawei.com/ Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin --- drivers/devfreq/devfreq.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 344e276165e4..9ab97164443e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1381,15 +1381,11 @@ int devfreq_remove_governor(struct devfreq_governor *governor) int ret; struct device *dev = devfreq->dev.parent; + if (!devfreq->governor) + continue; + if (!strncmp(devfreq->governor->name, governor->name, DEVFREQ_NAME_LEN)) { - /* we should have a devfreq governor! */ - if (!devfreq->governor) { - dev_warn(dev, "%s: Governor %s NOT present\n", - __func__, governor->name); - continue; - /* Fall through */ - } ret = devfreq->governor->event_handler(devfreq, DEVFREQ_GOV_STOP, NULL); if (ret) { -- 2.39.5