[RESEND PATCH 1/2] firmware: arm_scpi: Add compatibility checks for shmem node

Sudeep Holla sudeep.holla at arm.com
Wed Jun 2 00:38:50 PDT 2021


The shared memory node used for communication between the firmware and
the OS should be compatible with one of the following:
	- amlogic,meson-gxbb-scp-shmem
	- amlogic,meson-axg-scp-shmem
	- arm,juno-scp-shmem
	- arm,scp-shmem
Add the check for the same while parsing the node before fetching the memory
regions.

Cc: Rob Herring <robh+dt at kernel.org>
Cc: Kevin Hilman <khilman at baylibre.com>
Cc: Neil Armstrong <narmstrong at baylibre.com>
Cc: Jerome Brunet <jbrunet at baylibre.com>
Signed-off-by: Sudeep Holla <sudeep.holla at arm.com>
---
 drivers/firmware/arm_scpi.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c
index d0dee37ad522..7b827258e163 100644
--- a/drivers/firmware/arm_scpi.c
+++ b/drivers/firmware/arm_scpi.c
@@ -897,6 +897,13 @@ static const struct of_device_id legacy_scpi_of_match[] = {
 	{},
 };
 
+static const struct of_device_id shmem_of_match[] = {
+	{ .compatible = "amlogic,meson-gxbb-scp-shmem", },
+	{ .compatible = "amlogic,meson-axg-scp-shmem", },
+	{ .compatible = "arm,juno-scp-shmem", },
+	{ .compatible = "arm,scp-shmem", },
+	{ }
+};
 static int scpi_probe(struct platform_device *pdev)
 {
 	int count, idx, ret;
@@ -933,6 +940,9 @@ static int scpi_probe(struct platform_device *pdev)
 		struct mbox_client *cl = &pchan->cl;
 		struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
 
+		if (!of_match_node(shmem_of_match, shmem))
+			return -ENXIO;
+
 		ret = of_address_to_resource(shmem, 0, &res);
 		of_node_put(shmem);
 		if (ret) {
-- 
2.25.1




More information about the linux-arm-kernel mailing list