mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
firmware: arm_scmi: Validate Powercap domains before state access
Powercap protocol v2 keeps local enable and last-cap state per domain. The v2 enable helpers and disabled-domain cap_set path indexed that state before checking that the supplied domain id was valid. Validate the domain before touching the per-domain state. Link: https://patch.msgid.link/20260517-scmi_fixes-v1-4-d86daec4defd@kernel.org Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
This commit is contained in:
parent
32bc5496b4
commit
fcca603c6a
|
|
@ -453,10 +453,14 @@ static int scmi_powercap_cap_set(const struct scmi_protocol_handle *ph,
|
|||
return -EINVAL;
|
||||
|
||||
/* Just log the last set request if acting on a disabled domain */
|
||||
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2 &&
|
||||
!pi->states[domain_id].enabled) {
|
||||
pi->states[domain_id].last_pcap = power_cap;
|
||||
return 0;
|
||||
if (PROTOCOL_REV_MAJOR(ph->version) >= 0x2) {
|
||||
if (!scmi_powercap_dom_info_get(ph, domain_id))
|
||||
return -EINVAL;
|
||||
|
||||
if (!pi->states[domain_id].enabled) {
|
||||
pi->states[domain_id].last_pcap = power_cap;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return __scmi_powercap_cap_set(ph, pi, domain_id,
|
||||
|
|
@ -637,6 +641,9 @@ static int scmi_powercap_cap_enable_set(const struct scmi_protocol_handle *ph,
|
|||
if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
|
||||
return -EINVAL;
|
||||
|
||||
if (!scmi_powercap_dom_info_get(ph, domain_id))
|
||||
return -EINVAL;
|
||||
|
||||
if (enable == pi->states[domain_id].enabled)
|
||||
return 0;
|
||||
|
||||
|
|
@ -678,6 +685,9 @@ static int scmi_powercap_cap_enable_get(const struct scmi_protocol_handle *ph,
|
|||
if (PROTOCOL_REV_MAJOR(ph->version) < 0x2)
|
||||
return 0;
|
||||
|
||||
if (!scmi_powercap_dom_info_get(ph, domain_id))
|
||||
return -EINVAL;
|
||||
|
||||
/*
|
||||
* Report always real platform state; platform could have ignored
|
||||
* a previous disable request. Default true on any error.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user