Skip to content

Commit 427c70d

Browse files
superm1jwrdegoede
authored andcommitted
platform/x86: thinkpad_acpi: Only update profile if successfully converted
Randomly a Lenovo Z13 will trigger a kernel warning traceback from this condition: ``` if (WARN_ON((profile < 0) || (profile >= ARRAY_SIZE(profile_names)))) ``` This happens because thinkpad-acpi always assumes that convert_dytc_to_profile() successfully updated the profile. On the contrary a condition can occur that when dytc_profile_refresh() is called the profile doesn't get updated as there is a -EOPNOTSUPP branch. Catch this situation and avoid updating the profile. Also log this into dynamic debugging in case any other modes should be added in the future. Fixes: c3bfcd4 ("platform/x86: thinkpad_acpi: Add platform profile support") Signed-off-by: Mario Limonciello <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hans de Goede <[email protected]> Signed-off-by: Hans de Goede <[email protected]>
1 parent 84c16d0 commit 427c70d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10308,6 +10308,7 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,
1030810308
return 0;
1030910309
default:
1031010310
/* Unknown function */
10311+
pr_debug("unknown function 0x%x\n", funcmode);
1031110312
return -EOPNOTSUPP;
1031210313
}
1031310314
return 0;
@@ -10493,8 +10494,8 @@ static void dytc_profile_refresh(void)
1049310494
return;
1049410495

1049510496
perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
10496-
convert_dytc_to_profile(funcmode, perfmode, &profile);
10497-
if (profile != dytc_current_profile) {
10497+
err = convert_dytc_to_profile(funcmode, perfmode, &profile);
10498+
if (!err && profile != dytc_current_profile) {
1049810499
dytc_current_profile = profile;
1049910500
platform_profile_notify();
1050010501
}

0 commit comments

Comments
 (0)