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 AFA83356A37 for ; Wed, 8 Apr 2026 07:00:29 +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=1775631629; cv=none; b=NCWBgdEROP9CQGdeVELc5oE9yxJ2AVNF4sCZHwFQJU3xcytafTSOLpkTHvV5eWjkfjK4H0VpXLAH6jzCW/p1q4WGN3xk7wOKbv56W6jXtRBcf/A/AlV8VL3OkR4WSTnaI6BtFm1iYSTZgCqkrVpn2qD9+/oTE3+rI/csum5Pt7c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775631629; c=relaxed/simple; bh=g7F/V40LKKfqNtTK41YKE8RKlxDwwqcyTLK5KwCOkSU=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=cXZ4BWYlm7oUfD4USpMsqh2wGmC+Kkk+UcePUYTbawmcEN38kOLm0lijryZIkXaMVXPcp2CVdoDl6Ge83HthUVdCp57IJPiol0kApkxY/6ZBYdSTpMj1Zpi1TMShqKG8iel6y0GpOW/zUPZDGMDnpQRvkeItXM02MrPiUyFwLLU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ltGdXdah; 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="ltGdXdah" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4681EC19424; Wed, 8 Apr 2026 07:00:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775631629; bh=g7F/V40LKKfqNtTK41YKE8RKlxDwwqcyTLK5KwCOkSU=; h=Subject:To:Cc:From:Date:From; b=ltGdXdahZe0l9Jcs1UqhqBuz4DAyRYNTnzoBcvjzlS947cgiQ9XnJZrZ47uvkxQi/ s2F2OJM+quDb6CtP6J5hcHXO8d+s17A92NLoN8j99DofXAwdc030qCHEpp//RSh7hI Nl6DDR+DTqT3Iah81IX9utB0F5xhvqS3nAab8FjQ= Subject: FAILED: patch "[PATCH] cpufreq: governor: fix double free in" failed to apply to 5.10-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:17 +0200 Message-ID: <2026040817-dotted-shredder-9229@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.10-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.10.y git checkout FETCH_HEAD git cherry-pick -x 6dcf9d0064ce2f3e3dfe5755f98b93abe6a98e1e # git commit -s git send-email --to '' --in-reply-to '2026040817-dotted-shredder-9229@gregkh' --subject-prefix 'PATCH 5.10.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);