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 26F1315FA91; Mon, 27 May 2024 19:26:13 +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=1716837973; cv=none; b=g2ORTWmTVZyU+PdkS2v9H7EEo6BS10q8x+E1uukOdv22QKqoDWy1or3nJKmbT4QTi0JDWxPEhobo7ssG2D4T97qbRGioCx2iAEFBFq4xLSSvviUdwXZbRyyOEpJT/b/l1cMCcksYjT5K8Vo0OkwkeUgg7HTPrCRBRedTwHi0OhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716837973; c=relaxed/simple; bh=N3wtOuo/82KjPtbqs1bsdAI3nh1uHnDv0oFMsc/FSm0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QRz4Nd1CYrjHpkdKkWFxZblyI0fNzutvzoEft323OPtCSte1pXYy8v1HPaYwdUH1ElDm50agI9mjQy1uknwgQwz60NxkkybnhzE+iAsSF71qZoH6v5X7xp2JLzeZQ9dR9GTcQVNSgHDoOlcTgsqgXWxPnpjhtgz8L5OxCdDFgME= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wi0sHeI4; 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="wi0sHeI4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B0745C2BBFC; Mon, 27 May 2024 19:26:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1716837973; bh=N3wtOuo/82KjPtbqs1bsdAI3nh1uHnDv0oFMsc/FSm0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wi0sHeI4rPZ+iWkBBP3+G5hfNbhV8bByA+YYOdKCTtMzreEP/VoNdPG09aZF0gNyB D3jhH7xHw0++Ty8hkUtug+6xotBclQVtFz0NvI6Gd9hsrd6llg0pi1wMxRafh9KY8U Ji+ftQrDy0x5faB24V5xx58/r1E7Th2GV+RTJEjk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Viresh Kumar , Lizhe , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 6.8 215/493] cpufreq: exit() callback is optional Date: Mon, 27 May 2024 20:53:37 +0200 Message-ID: <20240527185637.351762776@linuxfoundation.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240527185626.546110716@linuxfoundation.org> References: <20240527185626.546110716@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.8-stable review patch. If anyone has any objections, please let me know. ------------------ From: Viresh Kumar [ Upstream commit b8f85833c05730d631576008daaa34096bc7f3ce ] The exit() callback is optional and shouldn't be called without checking a valid pointer first. Also, we must clear freq_table pointer even if the exit() callback isn't present. Signed-off-by: Viresh Kumar Fixes: 91a12e91dc39 ("cpufreq: Allow light-weight tear down and bring up of CPUs") Fixes: f339f3541701 ("cpufreq: Rearrange locking in cpufreq_remove_dev()") Reported-by: Lizhe Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 3c2c955fbbbd6..86f1bc7754ea6 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1670,10 +1670,13 @@ static void __cpufreq_offline(unsigned int cpu, struct cpufreq_policy *policy) */ if (cpufreq_driver->offline) { cpufreq_driver->offline(policy); - } else if (cpufreq_driver->exit) { - cpufreq_driver->exit(policy); - policy->freq_table = NULL; + return; } + + if (cpufreq_driver->exit) + cpufreq_driver->exit(policy); + + policy->freq_table = NULL; } static int cpufreq_offline(unsigned int cpu) @@ -1731,7 +1734,7 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif) } /* We did light-weight exit earlier, do full tear down now */ - if (cpufreq_driver->offline) + if (cpufreq_driver->offline && cpufreq_driver->exit) cpufreq_driver->exit(policy); up_write(&policy->rwsem); -- 2.43.0