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 2C92B3624B0 for ; Wed, 8 Apr 2026 07:00:27 +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=1775631627; cv=none; b=rUbLfJoCCVpZTa4cXfK6sxpeq9yjL5k/64NYWHk6pavtmA1qDiBtM9RTKcFjjk2swYSN3JPw3C3YPLKtSMvERSyKIqsk1Nxf8MhH28Fb7KunX+46s/DMRDAZG65zjRzdbbQdOt1SXfSqhQla8V5JMC+UEzcsV1f6p6z+1+b+f5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775631627; c=relaxed/simple; bh=T8hFOWAxWuASiKQKd5iMJLHzixkHJBjxLbMouM9tmeU=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=jentsGVQ+ovW2N9zruK3UTFGBZs3EekaWOubfR+AnDuNXEeAnUfauYEBJYM+FGbA6un3Ngwh+KAPJTxIeOsM5ChwZHJye7P3w26Jyjwg7z0AaJ5e7mflEE/7XirIGHwUPNqmi6KzrPtQGWGeUtujsGiTfa9+MyaVl5Mo3JtDz5Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=vzW4r/yd; 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="vzW4r/yd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6A17C19424; Wed, 8 Apr 2026 07:00:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775631627; bh=T8hFOWAxWuASiKQKd5iMJLHzixkHJBjxLbMouM9tmeU=; h=Subject:To:Cc:From:Date:From; b=vzW4r/ydObHYORw++09e9PxfrQqJL1OoS3+BxXX74k3eYT1ZR8y1fVFg4Sf/jG5Wl BLU/O2OJOvjRmow3ZNKl3DrvtWsPo1rTw2QlaTV+5m+FAEnUaUgDEntsHpzftgPreS 3Vghq5VVSTZ/H2WqH0y/sAoyAU9HUeXnJLVftN7c= Subject: FAILED: patch "[PATCH] cpufreq: governor: fix double free in" failed to apply to 5.15-stable tree To: lgs201920130244@gmail.com,rafael.j.wysocki@intel.com,stable@vger.kernel.org,viresh.kumar@linaro.org,zhongqiu.han@oss.qualcomm.com Cc: From: Date: Wed, 08 Apr 2026 09:00:16 +0200 Message-ID: <2026040816-flattop-footing-328d@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 6dcf9d0064ce2f3e3dfe5755f98b93abe6a98e1e # git commit -s git send-email --to '' --in-reply-to '2026040816-flattop-footing-328d@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 6dcf9d0064ce2f3e3dfe5755f98b93abe6a98e1e Mon Sep 17 00:00:00 2001 From: Guangshuo Li Date: Wed, 1 Apr 2026 10:45:35 +0800 Subject: [PATCH] cpufreq: governor: fix double free in cpufreq_dbs_governor_init() error path When kobject_init_and_add() fails, cpufreq_dbs_governor_init() calls kobject_put(&dbs_data->attr_set.kobj). The kobject release callback cpufreq_dbs_data_release() calls gov->exit(dbs_data) and kfree(dbs_data), but the current error path then calls gov->exit(dbs_data) and kfree(dbs_data) again, causing a double free. Keep the direct kfree(dbs_data) for the gov->init() failure path, but after kobject_init_and_add() has been called, let kobject_put() handle the cleanup through cpufreq_dbs_data_release(). Fixes: 4ebe36c94aed ("cpufreq: Fix kobject memleak") Signed-off-by: Guangshuo Li Reviewed-by: Zhongqiu Han Acked-by: Viresh Kumar Cc: All applicable Link: https://patch.msgid.link/20260401024535.1395801-1-lgs201920130244@gmail.com Signed-off-by: Rafael J. Wysocki diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c index acf101878733..86f35e451914 100644 --- a/drivers/cpufreq/cpufreq_governor.c +++ b/drivers/cpufreq/cpufreq_governor.c @@ -468,13 +468,13 @@ int cpufreq_dbs_governor_init(struct cpufreq_policy *policy) /* Failure, so roll back. */ pr_err("initialization failed (dbs_data kobject init error %d)\n", ret); - kobject_put(&dbs_data->attr_set.kobj); - policy->governor_data = NULL; if (!have_governor_per_policy()) gov->gdbs_data = NULL; - gov->exit(dbs_data); + + kobject_put(&dbs_data->attr_set.kobj); + goto free_policy_dbs_info; free_dbs_data: kfree(dbs_data);