diff options
author | Cristian Marussi <cristian.marussi@arm.com> | 2022-08-17 18:27:27 +0100 |
---|---|---|
committer | Sudeep Holla <sudeep.holla@arm.com> | 2022-08-22 18:01:45 +0100 |
commit | 1ecb7d27b1af6705e9a4e94415b4d8cc8cf2fbfb (patch) | |
tree | 571408f5a8bc6befab7993c83177e7bcaee2a020 /drivers | |
parent | 2e42b1652df00daf7000011ec9917f2eda534190 (diff) | |
download | linux-stable-1ecb7d27b1af6705e9a4e94415b4d8cc8cf2fbfb.tar.gz linux-stable-1ecb7d27b1af6705e9a4e94415b4d8cc8cf2fbfb.tar.bz2 linux-stable-1ecb7d27b1af6705e9a4e94415b4d8cc8cf2fbfb.zip |
firmware: arm_scmi: Improve checks in the info_get operations
SCMI protocols abstract and expose a number of protocol specific
resources like clocks, sensors and so on. Information about such
specific domain resources are generally exposed via an `info_get`
protocol operation.
Improve the sanity check on these operations where needed.
Link: https://lore.kernel.org/r/20220817172731.1185305-3-cristian.marussi@arm.com
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/firmware/arm_scmi/clock.c | 6 | ||||
-rw-r--r-- | drivers/firmware/arm_scmi/sensors.c | 3 |
2 files changed, 8 insertions, 1 deletions
diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 3ed7ae0d6781..96060bf90a24 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -450,9 +450,13 @@ static int scmi_clock_count_get(const struct scmi_protocol_handle *ph) static const struct scmi_clock_info * scmi_clock_info_get(const struct scmi_protocol_handle *ph, u32 clk_id) { + struct scmi_clock_info *clk; struct clock_info *ci = ph->get_priv(ph); - struct scmi_clock_info *clk = ci->clk + clk_id; + if (clk_id >= ci->num_clocks) + return NULL; + + clk = ci->clk + clk_id; if (!clk->name[0]) return NULL; diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 7288c6117838..7d0c7476d206 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -948,6 +948,9 @@ scmi_sensor_info_get(const struct scmi_protocol_handle *ph, u32 sensor_id) { struct sensors_info *si = ph->get_priv(ph); + if (sensor_id >= si->num_sensors) + return NULL; + return si->sensors + sensor_id; } |