Skip to content

Commit

Permalink
thermal/int340x_thermal: Prevent page fault on .set_mode() op
Browse files Browse the repository at this point in the history
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 <bsz@semihalf.com>
Reviewed-by: Pandruvada, Srinivas <srinivas.pandruvada@linux.intel.com>
[ rzhang: Add Fixes tag ]
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Link: https://lore.kernel.org/r/20200708134613.131555-1-bsz@semihalf.com
  • Loading branch information
Bartosz Szczepanek authored and Zhang Rui committed Jul 14, 2020
1 parent 9ebcfad commit 3ce315a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion drivers/thermal/intel/int340x_thermal/int3400_thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,16 @@ static int int3400_thermal_run_osc(acpi_handle handle,
acpi_status status;
int result = 0;
struct acpi_osc_context context = {
.uuid_str = int3400_thermal_uuids[uuid],
.uuid_str = NULL,
.rev = 1,
.cap.length = 8,
};

if (uuid < 0 || uuid >= INT3400_THERMAL_MAXIMUM_UUID)
return -EINVAL;

context.uuid_str = int3400_thermal_uuids[uuid];

buf[OSC_QUERY_DWORD] = 0;
buf[OSC_SUPPORT_DWORD] = enable;

Expand Down

0 comments on commit 3ce315a

Please sign in to comment.