firmware: arm_scmi: Add compatibility checks for shmem node
authorSudeep Holla <sudeep.holla@arm.com>
Wed, 2 Jun 2021 07:38:51 +0000 (08:38 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Tue, 8 Jun 2021 14:08:53 +0000 (15:08 +0100)
The shared memory node used for communication between the firmware and
the OS should be compatible with "arm,scmi-shmem". Add the check for the
same while parsing the node before fetching the memory regions.

Link: https://lore.kernel.org/r/20210602073851.1005607-2-sudeep.holla@arm.com
Cc: Rob Herring <robh+dt@kernel.org>
Cc: Cristian Marussi <cristian.marussi@arm.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Jim Quinlan <jim2101024@gmail.com>
Cc: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Cristian Marussi <cristian.marussi@arm.com>
Tested-by: Cristian Marussi <cristian.marussi@arm.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/mailbox.c
drivers/firmware/arm_scmi/smc.c

index 4626404..e3dcb58 100644 (file)
@@ -69,6 +69,9 @@ static int mailbox_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
                return -ENOMEM;
 
        shmem = of_parse_phandle(cdev->of_node, "shmem", idx);
+       if (!of_device_is_compatible(shmem, "arm,scmi-shmem"))
+               return -ENXIO;
+
        ret = of_address_to_resource(shmem, 0, &res);
        of_node_put(shmem);
        if (ret) {
index fcbe267..bed5596 100644 (file)
@@ -76,6 +76,9 @@ static int smc_chan_setup(struct scmi_chan_info *cinfo, struct device *dev,
                return -ENOMEM;
 
        np = of_parse_phandle(cdev->of_node, "shmem", 0);
+       if (!of_device_is_compatible(np, "arm,scmi-shmem"))
+               return -ENXIO;
+
        ret = of_address_to_resource(np, 0, &res);
        of_node_put(np);
        if (ret) {