Skip to contentSkip to conversation

arm: socfpga: Fix mailbox command length checking

PATCH New Ley Foon Tan 2 participants 4 messages Apr 11, 2019 – Apr 16, 2019

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

PATCH 1/1 arm: socfpga: Fix mailbox command length checking

A mailbox command including header + arguments.
But, "len" only including length of arguments, it missed the length of header in checking.
Includes length of header (1) when checking the space size.

---
 arch/arm/mach-socfpga/mailbox_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/mailbox_s10.c +1 -1
index 3c33223936..8363c93e90 100644
@@ -59,7 +59,7 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
 	 */
 	if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
 	    ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
-	     MBOX_CMD_BUFFER_SIZE) < len)
+	     MBOX_CMD_BUFFER_SIZE) < (len + 1))
 		return -ENOMEM;
 
 	/* write header to circular buffer */
Signature · 1 line
2.19.0
#1 lore raw

PATCH v2 1/1 arm: socfpga: mailbox: Fix off-by-one error on command length checking

A mailbox command contains of header + arguments.
But, "len" is only including length of arguments, off-by-one for length of header in checking.
Includes length of header (1) when checking the space size.

---
 arch/arm/mach-socfpga/mailbox_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/mailbox_s10.c +1 -1
index 3c33223936..8363c93e90 100644
@@ -59,7 +59,7 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
 	 */
 	if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
 	    ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
-	     MBOX_CMD_BUFFER_SIZE) < len)
+	     MBOX_CMD_BUFFER_SIZE) < (len + 1))
 		return -ENOMEM;
 
 	/* write header to circular buffer */
Signature · 1 line
2.19.0
#2 lore raw

PATCH v2 1/1 arm: socfpga: mailbox: Fix off-by-one error on command length checking

Quoted 17 lines · Ley Foon Tan

A mailbox command contains of header + arguments.
But, "len" is only including length of arguments, off-by-one for length of header in checking.
Includes length of header (1) when checking the space size.

---
 arch/arm/mach-socfpga/mailbox_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/mailbox_s10.c +0 -0
index 3c33223936..8363c93e90 100644

arch/arm/mach-socfpga/mailbox_s10.c static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len, · line 65

Quoted 8 lines
arch/arm/mach-socfpga/mailbox_s10.c +1 -1
@@ -59,7 +59,7 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
         */
        if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
            ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
-            MBOX_CMD_BUFFER_SIZE) < len)
+            MBOX_CMD_BUFFER_SIZE) < (len + 1))
                return -ENOMEM;
 
        /* write header to circular buffer */

Hi Marek

Are you okay with the new commit message?
Thanks.

Regards
Ley Foon

#3 lore raw

PATCH 1/1 arm: socfpga: Fix mailbox command length checking

In reply to Ley Foon Tan
Quoted 26 lines · Ley Foon Tan

A mailbox command including header + arguments.
But, "len" only including length of arguments, it missed the length of header in checking.
Includes length of header (1) when checking the space size.

---
 arch/arm/mach-socfpga/mailbox_s10.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-socfpga/mailbox_s10.c +1 -2
index 3c33223936..8363c93e90 100644
@@ -59,7 +59,7 @@ static __always_inline int mbox_fill_cmd_circular_buff(u32 header, u32 len,
         */
        if (((cin + 1) % MBOX_CMD_BUFFER_SIZE) == cout ||
            ((MBOX_CMD_BUFFER_SIZE - cin + cout - 1) %
-            MBOX_CMD_BUFFER_SIZE) < len)
+            MBOX_CMD_BUFFER_SIZE) < (len + 1))
                return -ENOMEM;
 
        /* write header to circular buffer */
--
Quoted 2 lines

2.19.0

Please ignore this, Resend accidentally.

Ley Foon