linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 5.19 01/29] firmware: arm_scmi: Improve checks in the info_get operations
@ 2022-10-02 22:48 Sasha Levin
  2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 02/29] firmware: arm_scmi: Harden accesses to the sensor domains Sasha Levin
                   ` (27 more replies)
  0 siblings, 28 replies; 29+ messages in thread
From: Sasha Levin @ 2022-10-02 22:48 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Cristian Marussi, Sudeep Holla, Sasha Levin, linux-arm-kernel

From: Cristian Marussi <cristian.marussi@arm.com>

[ Upstream commit 1ecb7d27b1af6705e9a4e94415b4d8cc8cf2fbfb ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/firmware/arm_scmi/clock.c   | 6 +++++-
 drivers/firmware/arm_scmi/sensors.c | 3 +++
 include/linux/scmi_protocol.h       | 4 ++--
 3 files changed, 10 insertions(+), 3 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;
 }
 
diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h
index 704111f63993..6dd50ac82d10 100644
--- a/include/linux/scmi_protocol.h
+++ b/include/linux/scmi_protocol.h
@@ -78,7 +78,7 @@ struct scmi_protocol_handle;
 struct scmi_clk_proto_ops {
 	int (*count_get)(const struct scmi_protocol_handle *ph);
 
-	const struct scmi_clock_info *(*info_get)
+	const struct scmi_clock_info __must_check *(*info_get)
 		(const struct scmi_protocol_handle *ph, u32 clk_id);
 	int (*rate_get)(const struct scmi_protocol_handle *ph, u32 clk_id,
 			u64 *rate);
@@ -460,7 +460,7 @@ enum scmi_sensor_class {
  */
 struct scmi_sensor_proto_ops {
 	int (*count_get)(const struct scmi_protocol_handle *ph);
-	const struct scmi_sensor_info *(*info_get)
+	const struct scmi_sensor_info __must_check *(*info_get)
 		(const struct scmi_protocol_handle *ph, u32 sensor_id);
 	int (*trip_point_config)(const struct scmi_protocol_handle *ph,
 				 u32 sensor_id, u8 trip_id, u64 trip_value);
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 29+ messages in thread

end of thread, other threads:[~2022-10-02 22:53 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-02 22:48 [PATCH AUTOSEL 5.19 01/29] firmware: arm_scmi: Improve checks in the info_get operations Sasha Levin
2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 02/29] firmware: arm_scmi: Harden accesses to the sensor domains Sasha Levin
2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 03/29] firmware: arm_scmi: Harden accesses to the reset domains Sasha Levin
2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 04/29] firmware: arm_scmi: Add SCMI PM driver remove routine Sasha Levin
2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 05/29] arm64: dts: rockchip: fix upper usb port on BPI-R2-Pro Sasha Levin
2022-10-02 22:48 ` [PATCH AUTOSEL 5.19 06/29] dmaengine: xilinx_dma: Fix devm_platform_ioremap_resource error handling Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 07/29] dmaengine: xilinx_dma: cleanup for fetching xlnx,num-fstores property Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 08/29] dmaengine: xilinx_dma: Report error in case of dma_set_mask_and_coherent API failure Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 09/29] wifi: iwlwifi: don't spam logs with NSS>2 messages Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 10/29] ARM: dts: fix Moxa SDIO 'compatible', remove 'sdhci' misnomer Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 11/29] drm/amdgpu/mes: zero the sdma_hqd_mask of 2nd SDMA engine for SDMA 6.0.1 Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 12/29] scsi: qedf: Fix a UAF bug in __qedf_probe() Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 13/29] net/ieee802154: fix uninit value bug in dgram_sendmsg Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 14/29] net: marvell: prestera: add support for for Aldrin2 Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 15/29] ALSA: hda/hdmi: Fix the converter reuse for the silent stream Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 16/29] um: Cleanup syscall_handler_t cast in syscalls_32.h Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 17/29] um: Cleanup compiler warning in arch/x86/um/tls_32.c Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 18/29] gpio: ftgpio010: Make irqchip immutable Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 19/29] Revert "block: freeze the queue earlier in del_gendisk" Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 20/29] arch: um: Mark the stack non-executable to fix a binutils warning Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 21/29] net: atlantic: fix potential memory leak in aq_ndev_close() Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 22/29] KVM: s390: Pass initialized arg even if unused Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 23/29] drm/amd/display: Fix double cursor on non-video RGB MPO Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 24/29] drm/amd/display: Assume an LTTPR is always present on fixed_vs links Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 25/29] drm/amd/display: update gamut remap if plane has changed Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 26/29] drm/amd/display: skip audio setup when audio stream is enabled Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 27/29] drm/amd/display: Fix DP MST timeslot issue when fallback happened Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 28/29] drm/amd/display: increase dcn315 pstate change latency Sasha Levin
2022-10-02 22:49 ` [PATCH AUTOSEL 5.19 29/29] Makefile.debug: set -g unconditional on CONFIG_DEBUG_INFO_SPLIT Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).