Skip to content

Commit 3ce315a

Browse files
thermal/int340x_thermal: Prevent page fault on .set_mode() op
Starting from commit "thermal/int340x_thermal: Don't require IDSP to exist", priv->current_uuid_index is initialized to -1. This value may be passed to int3400_thermal_run_osc() from int3400_thermal_set_mode, contributing to page fault when accessing int3400_thermal_uuids array at index -1. This commit adds a check on uuid value to int3400_thermal_run_osc. Fixes: 8d485da ("thermal/int340x_thermal: Don't require IDSP to exist") Signed-off-by: Bartosz Szczepanek <[email protected]> Reviewed-by: Pandruvada, Srinivas <[email protected]> [ rzhang: Add Fixes tag ] Signed-off-by: Zhang Rui <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 9ebcfad commit 3ce315a

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

drivers/thermal/intel/int340x_thermal/int3400_thermal.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,16 @@ static int int3400_thermal_run_osc(acpi_handle handle,
216216
acpi_status status;
217217
int result = 0;
218218
struct acpi_osc_context context = {
219-
.uuid_str = int3400_thermal_uuids[uuid],
219+
.uuid_str = NULL,
220220
.rev = 1,
221221
.cap.length = 8,
222222
};
223223

224+
if (uuid < 0 || uuid >= INT3400_THERMAL_MAXIMUM_UUID)
225+
return -EINVAL;
226+
227+
context.uuid_str = int3400_thermal_uuids[uuid];
228+
224229
buf[OSC_QUERY_DWORD] = 0;
225230
buf[OSC_SUPPORT_DWORD] = enable;
226231

0 commit comments

Comments
 (0)