From nobody Mon Sep 28 06:36:11 2026 Received: from mail-pj2-f10.google.com (mail-pj2-f10.google.com [74.125.227.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9B4B1355819 for ; Tue, 25 Aug 2026 13:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.227.138 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787663657; cv=none; b=KA06acaaj2LdfkpGRmUWKwyB8EK77n5q55U0ywpzYIWhmgcMkWqkyKSU08s5Gh8muyaSp06qFNraKp5QTyWRwOjJhJGC0cPYkNCnf85Oxk7HYL0yVKcnNLzhL0pAaNTd2FEB6pdX+gCi3LaoR+8NLw6OsQFZz6Dzk+42ABY9kUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787663657; c=relaxed/simple; bh=4ISMhpMniE/8ybSFGW89rkvY0P+M11KGu0j76X6uQkY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=kHcZgVSb7bvS2Pt5t/1OudhdF3eJiZL7pebOuR2BhEd+RKNlHfIFgPKP6htQFRaChbqYmL+fXqfND0xXFMFReFMCYl5nJiOUfUfdmqAV1e/MtyyRhpYm7ZBrCwdAODlhJyzCVwjZVZZw3oDF+U8zFXv8dVGifxvBRu9bRTIQvuQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=74.125.227.138 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj2-f10.google.com with SMTP id d9443c01a7336-2d3a0a81329so50095605ad.1 for ; Tue, 25 Aug 2026 06:14:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787663652; x=1788268452; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=3jSubmSbLPyvICbixwT9x8CgWie9Qul0y0X7w0A8fPs=; b=aZNV692pVMCSZnmgTCy3lufpwhbJywh/TcqJDHPtQkpvjDZm6Cad4TGRoPrEQfKM4f Xa0zqxdAi3QQcnZR9OBmXHB/Dc3JdyHHu3b5+JRDukCoQFGFBzs00DsUSgdluMn/dl/W 0PskWHTOD+frihFp7xSUBH2egoe2hEPQXfEMnToIwXlXf0RRcTc8MICRcYswMxawUqdj q0EZxJcl6mS7zI7hC66s+lLopeesaarhNuRO1MB+tWmuBiIKDvT+syggNfHVIy5kzxCR oBbhVtD80LSl60nSHXzy3UKCU1Y5K71e1c5FyX0oOYTzlmefHibaJc4p1AboihykF5Kk MvTg== X-Forwarded-Encrypted: i=1; AHgh+RozYG81JOef7x4yRvDCH3UUB6fZsoP1ylr93kLKEprz83dnOPdfH3a4wNS2i3UKhC28lw49rjpS22MT+to=@vger.kernel.org X-Gm-Message-State: AFuF++mbxDkpdrHGdI2vmWL7l2fPDVnCAoY+4LquPlgld78Z+vyxdUL1 cAbw37rf0n536RRPPgMijlz/DmfC5BVdcPqq0vQ0yTpUyCCLbytrq2fs X-Gm-Gg: AR+sD12DfgPc1ZZcq4Fej9WmsJ+qLk7y+0lbpSlKk5/BZgjCKCHW7dcejd+i+RNvPtd ZM9mN1RkexZ6+NdiOtcJdKUN0PnpjOcb0saZKeh4s3ssTLde3XP5ZoT3l/5tdYtd4Fu8Rb3zQpb qjU8F7tRx0X6SFFkOgHkDB318NAq45MjlviW1ZTZj5leA2yGdWNi2TgwZUhUxj5W7oH2FAgVHJF wM0RvAOvZ/xFffJJvZGBa3qY2nq99flalb7+cKMSlDxo6jXIzmt2F7fUufdGyK5aizKDPtgTxug +LvbHN+tHxhY4erPmBLVP35F8h3zx+cQl4YuYW4xjp4uoWfaQsZysvFk6upDD6mUnOnpTsaam4/ YFBuM+QrSmOj+6QMiXNlhVwu0HD8rY5lg1Gk7irtQj9u9BVkM5dGDM407K9f26f8wjRyjiR6QMF C6UGcUC3kEQSBPe0uDIf/QKMzrhaD/TpJDTTdCIiV5hKX7eFjqdLodJgGvp9cOohoA8pNZgLbU9 ohhCUcEZQ== X-Received: by 2002:a17:902:f546:b0:2bf:dd0:c8b1 with SMTP id d9443c01a7336-2d6dc655395mr110099795ad.0.1787663651649; Tue, 25 Aug 2026 06:14:11 -0700 (PDT) Received: from kylin-XiaoXinPro-16-AHP9.. ([116.128.244.169]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d676788239sm27087285ad.18.2026.08.25.06.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Aug 2026 06:14:11 -0700 (PDT) From: Xueqin Luo To: Huang Rui , Mario Limonciello , "Rafael J . Wysocki" , Viresh Kumar Cc: Perry Yuan , K Prateek Nayak , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq/amd-pstate: Restore previous EPP if profile_name allocation fails Date: Tue, 25 Aug 2026 21:14:00 +0800 Message-ID: <20260825131400.1509428-1-luoxueqin@kylinos.cn> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" amd_pstate_set_dynamic_epp() first applies the EPP value derived from the current platform profile via amd_pstate_set_epp() and only then allocates the profile name and registers the platform profile handler and the power supply notifier. All failures after the EPP has been programmed jump to the cleanup label, which restores the previously programmed EPP value. However, if the kasprintf() of the profile name fails, the function returns -ENOMEM directly, bypassing the cleanup label, so the EPP value programmed above is never rolled back even though enabling dynamic EPP has failed. Make the allocation failure path jump to the cleanup label as well, so that the previous EPP value is restored consistently on all error paths. Fixes: b7294b627598 ("cpufreq/amd-pstate: Add dynamic EPP as an "energy_per= formance_preference" mode") Signed-off-by: Xueqin Luo --- drivers/cpufreq/amd-pstate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index d4ff8b228f86..083094d23bff 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -1292,8 +1292,10 @@ static int amd_pstate_set_dynamic_epp(struct cpufreq= _policy *policy) return ret; =20 cpudata->profile_name =3D kasprintf(GFP_KERNEL, "amd-pstate-epp-cpu%d", c= pudata->cpu); - if (!cpudata->profile_name) - return -ENOMEM; + if (!cpudata->profile_name) { + ret =3D -ENOMEM; + goto cleanup; + } =20 cpudata->ppdev =3D platform_profile_register(get_cpu_device(policy->cpu), cpudata->profile_name, --=20 2.43.0