From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marek Vasut Date: Thu, 11 Apr 2019 09:58:14 +0200 Subject: [U-Boot] [PATCH] arm: socfpga: Fix mailbox command length checking In-Reply-To: <1554968374-24613-1-git-send-email-ley.foon.tan@intel.com> References: <1554968374-24613-1-git-send-email-ley.foon.tan@intel.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 4/11/19 9:39 AM, Ley Foon Tan wrote: > 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. I think the commit message could use some improvement, maybe reword it so it's clear what you're fixing here. I guess it's some off-by-one error ? > Signed-off-by: Ley Foon Tan > Signed-off-by: Chee Hong Ang > --- > arch/arm/mach-socfpga/mailbox_s10.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c > index 3c33223936..8363c93e90 100644 > --- a/arch/arm/mach-socfpga/mailbox_s10.c > +++ b/arch/arm/mach-socfpga/mailbox_s10.c > @@ -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 */ > -- Best regards, Marek Vasut