linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
@ 2025-01-23  6:34 Peng Fan (OSS)
  2025-01-23 12:20 ` Sudeep Holla
  2025-02-17 15:51 ` Sudeep Holla
  0 siblings, 2 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2025-01-23  6:34 UTC (permalink / raw)
  To: sudeep.holla, cristian.marussi
  Cc: arm-scmi, linux-arm-kernel, linux-kernel, Peng Fan, Jacky Bai,
	Shengjiu Wang, Jason Liu

From: Peng Fan <peng.fan@nxp.com>

'struct scmi_imx_misc_ctrl_set_in' has a zero length array in the end,
so sizeof will not count 'value[]', and txsize is smaller than actual
size for tx,and SCMI firmware will take this protocol error.

Fix this by enlarge the txsize with 'num * 4' 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>
---

V1:
 Patch is cherry-picked from downstream, so tags are kept.

 drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
index 83b69fc4fba5..fe770d7fdde6 100644
--- a/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
+++ b/drivers/firmware/arm_scmi/vendors/imx/imx-sm-misc.c
@@ -254,7 +254,7 @@ 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),
+	ret = ph->xops->xfer_get_init(ph, SCMI_IMX_MISC_CTRL_SET, sizeof(*in) + num * 4,
 				      0, &t);
 	if (ret)
 		return ret;
-- 
2.37.1



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

* Re: [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
  2025-01-23  6:34 [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set Peng Fan (OSS)
@ 2025-01-23 12:20 ` Sudeep Holla
  2025-01-24  1:13   ` Peng Fan
  2025-02-17 15:51 ` Sudeep Holla
  1 sibling, 1 reply; 4+ messages in thread
From: Sudeep Holla @ 2025-01-23 12:20 UTC (permalink / raw)
  To: Peng Fan (OSS)
  Cc: cristian.marussi, arm-scmi, Sudeep Holla, linux-arm-kernel,
	linux-kernel, Peng Fan, Jacky Bai, Shengjiu Wang, Jason Liu

On Thu, Jan 23, 2025 at 02:34:41PM +0800, Peng Fan (OSS) wrote:
> From: Peng Fan <peng.fan@nxp.com>
> 
> 'struct scmi_imx_misc_ctrl_set_in' has a zero length array in the end,
> so sizeof will not count 'value[]', and txsize is smaller than actual
> size for tx,and SCMI firmware will take this protocol error.
> 
> Fix this by enlarge the txsize with 'num * 4' 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>
> ---
> 
> V1:
>  Patch is cherry-picked from downstream, so tags are kept.
>

I don't if Ack is really helpful, but Tested-by is as we can't test it
on any other platform. But it would be better if provided on the list
instead of coming pre-packaged like this in the future. I will add it
as fix soon. Thanks!

-- 
Regards,
Sudeep


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

* RE: [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
  2025-01-23 12:20 ` Sudeep Holla
@ 2025-01-24  1:13   ` Peng Fan
  0 siblings, 0 replies; 4+ messages in thread
From: Peng Fan @ 2025-01-24  1:13 UTC (permalink / raw)
  To: Sudeep Holla, Peng Fan (OSS)
  Cc: cristian.marussi@arm.com, arm-scmi@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Jacky Bai, S.J. Wang, Jason Liu

> Subject: Re: [PATCH] firmware: arm_scmi: imx: Correct tx size of
> scmi_imx_misc_ctrl_set
> 
> On Thu, Jan 23, 2025 at 02:34:41PM +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@nxp.com>
> >
> > 'struct scmi_imx_misc_ctrl_set_in' has a zero length array in the end,
> > so sizeof will not count 'value[]', and txsize is smaller than actual
> > size for tx,and SCMI firmware will take this protocol error.
> >
> > Fix this by enlarge the txsize with 'num * 4' 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>
> > ---
> >
> > V1:
> >  Patch is cherry-picked from downstream, so tags are kept.
> >
> 
> I don't if Ack is really helpful, but Tested-by is as we can't test it on any
> other platform. But it would be better if provided on the list instead of
> coming pre-packaged like this in the future. 

I see. I'll follow that next time.

Thanks,
Peng.

I will add it as fix soon.
> Thanks!
> 
> --
> Regards,
> Sudeep


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

* Re: [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
  2025-01-23  6:34 [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set Peng Fan (OSS)
  2025-01-23 12:20 ` Sudeep Holla
@ 2025-02-17 15:51 ` Sudeep Holla
  1 sibling, 0 replies; 4+ messages in thread
From: Sudeep Holla @ 2025-02-17 15:51 UTC (permalink / raw)
  To: cristian.marussi, Peng Fan (OSS)
  Cc: Sudeep Holla, arm-scmi, linux-arm-kernel, linux-kernel, Peng Fan,
	Jacky Bai, Shengjiu Wang, Jason Liu

On Thu, 23 Jan 2025 14:34:41 +0800, Peng Fan (OSS) wrote:
> 'struct scmi_imx_misc_ctrl_set_in' has a zero length array in the end,
> so sizeof will not count 'value[]', and txsize is smaller than actual
> size for tx,and SCMI firmware will take this protocol error.
> 
> Fix this by enlarge the txsize with 'num * 4' to count in the size of
> data.
> 
> [...]

Applied with some minor changes to sudeep.holla/linux (for-next/scmi/fixes), thanks!

[1/1] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set
      https://git.kernel.org/sudeep.holla/c/ab027c488fc4
--
Regards,
Sudeep



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

end of thread, other threads:[~2025-02-17 17:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-23  6:34 [PATCH] firmware: arm_scmi: imx: Correct tx size of scmi_imx_misc_ctrl_set Peng Fan (OSS)
2025-01-23 12:20 ` Sudeep Holla
2025-01-24  1:13   ` Peng Fan
2025-02-17 15:51 ` Sudeep Holla

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).