Skip to contentSkip to conversation

remoteproc/mediatek: fix invalid use of sizeof in scp_ipi_init()

PATCH Applied Wei Yongjun 3 participants 3 messages May 9, 2020 – May 11, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remoteproc/mediatek: fix invalid use of sizeof in scp_ipi_init()

sizeof() when applied to a pointer typed expression gives the size of the pointer, not that of the pointed data.

Fixes 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")
---
 drivers/remoteproc/mtk_scp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/mtk_scp.c +2 -2
index 2bead57c9cf9..ac13e7b046a6 100644
@@ -132,8 +132,8 @@ static int scp_ipi_init(struct mtk_scp *scp)
 		(struct mtk_share_obj __iomem *)(scp->sram_base + recv_offset);
 	scp->send_buf =
 		(struct mtk_share_obj __iomem *)(scp->sram_base + send_offset);
-	memset_io(scp->recv_buf, 0, sizeof(scp->recv_buf));
-	memset_io(scp->send_buf, 0, sizeof(scp->send_buf));
+	memset_io(scp->recv_buf, 0, sizeof(*scp->recv_buf));
+	memset_io(scp->send_buf, 0, sizeof(*scp->send_buf));
 
 	return 0;
 }
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Wei Yongjun

sizeof() when applied to a pointer typed expression gives the size of the pointer, not that of the pointed data.

Fixes 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")
---
 drivers/remoteproc/mtk_scp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/mtk_scp.c +0 -0
index 2bead57c9cf9..ac13e7b046a6 100644

drivers/remoteproc/mtk_scp.c static int scp_ipi_init(struct mtk_scp *scp) · line 135

Quoted 6 lines
drivers/remoteproc/mtk_scp.c +2 -2
@@ -132,8 +132,8 @@ static int scp_ipi_init(struct mtk_scp *scp)
                (struct mtk_share_obj __iomem *)(scp->sram_base + recv_offset);
        scp->send_buf >                 (struct mtk_share_obj __iomem *)(scp->sram_base + send_offset);
-       memset_io(scp->recv_buf, 0, sizeof(scp->recv_buf));
-       memset_io(scp->send_buf, 0, sizeof(scp->send_buf));
+       memset_io(scp->recv_buf, 0, sizeof(*scp->recv_buf));
+       memset_io(scp->send_buf, 0, sizeof(*scp->send_buf));
Quoted 6 lines
drivers/remoteproc/mtk_scp.c +0 -0
        return 0;
 }
 
 
#2 lore raw
In reply to Wei Yongjun
This patch was applied to andersson/remoteproc.git (refs/heads/for-next).

Hello:

This patch was applied to andersson/remoteproc.git (refs/heads/for-next).

Quoted 8 lines · On Sat, 9 May 2020 08:42:37 +0000 you wrote:

sizeof() when applied to a pointer typed expression gives the size of the pointer, not that of the pointed data.

Fixes 63c13d61eafe ("remoteproc/mediatek: add SCP support for mt8183")

[...]

Here is a summary with links:
- [-next] remoteproc/mediatek: fix invalid use of sizeof in scp_ipi_init()

    https://git.kernel.org/andersson/remoteproc/c/8096f80a5c09b716be207eb042c4e40d6cdefbd2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/pwbot