]> www.infradead.org Git - users/willy/pagecache.git/commitdiff
firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
authorPeng Fan <peng.fan@nxp.com>
Thu, 23 Jan 2025 06:34:41 +0000 (14:34 +0800)
committerSudeep Holla <sudeep.holla@arm.com>
Thu, 13 Feb 2025 14:27:37 +0000 (14:27 +0000)
'struct scmi_imx_misc_ctrl_set_in' has a zero length array in the end,
The sizeof will not count 'value[]', and hence Tx size will be smaller
than actual size for Tx,and SCMI firmware will flag this as protocol
error.

Fix this by enlarge the Tx size with 'num * sizeof(__le32)' to count in
the size of data.

Fixes: 61c9f03e22fc ("firmware: arm_scmi: Add initial support for i.MX MISC protocol")
Reviewed-by: Jacky Bai <ping.bai@nxp.com>
Tested-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Acked-by: Jason Liu <jason.hui.liu@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Message-Id: <20250123063441.392555-1-peng.fan@oss.nxp.com>
(sudeep.holla: Commit rewording and replace hardcoded sizeof(__le32) value)
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c

index 83b69fc4fba5b4c8cf578517ffed7a01bfaccf12..a8915d3b4df518719d56bfff38922625ad9b70f6 100644 (file)
@@ -254,8 +254,8 @@ static int scmi_imx_misc_ctrl_set(const struct scmi_protocol_handle *ph,
        if (num > max_num)
                return -EINVAL;
 
-       ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET, sizeof(*in),
-                                     0, &t);
+       ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET,
+                                     sizeof(*in) + num * sizeof(__le32), 0, &t);
        if (ret)
                return ret;