diff mbox series

[v1,2/5] arm: socfpga: mailbox: Always read mailbox responses before returning status

Message ID 20200812015625.40790-3-chee.hong.ang@intel.com
State Accepted
Commit 833230ed33684f399aae84633f4992106b6d3949
Delegated to: Simon Goldschmidt
Headers show
Series SoCFPGA mailbox driver fixes and enhancements | expand

Commit Message

Ang, Chee Hong Aug. 12, 2020, 1:56 a.m. UTC
Mailbox driver should always check for the length of the response
and read the response data before returning the response status to
caller.

Signed-off-by: Chee Hong Ang <chee.hong.ang@intel.com>
---
 arch/arm/mach-socfpga/mailbox_s10.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Ley Foon Tan Sept. 4, 2020, 9:39 a.m. UTC | #1
> -----Original Message-----
> From: Ang, Chee Hong <chee.hong.ang@intel.com>
> Sent: Wednesday, August 12, 2020 9:56 AM
> To: u-boot@lists.denx.de
> Cc: Marek Vasut <marex@denx.de>; Simon Goldschmidt
> <simon.k.r.goldschmidt@gmail.com>; Tom Rini <trini@konsulko.com>; See,
> Chin Liang <chin.liang.see@intel.com>; Tan, Ley Foon
> <ley.foon.tan@intel.com>; Ang, Chee Hong <chee.hong.ang@intel.com>;
> Chee, Tien Fong <tien.fong.chee@intel.com>; Lim, Elly Siew Chin
> <elly.siew.chin.lim@intel.com>
> Subject: [PATCH v1 2/5] arm: socfpga: mailbox: Always read mailbox
> responses before returning status
> 
> Mailbox driver should always check for the length of the response and read
> the response data before returning the response status to caller.
> 
> Signed-off-by: Chee Hong Ang <chee.hong.ang@intel.com>
> ---
>  arch/arm/mach-socfpga/mailbox_s10.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-
> socfpga/mailbox_s10.c
> index 729d9b04fa..e8a587f007 100644
> --- a/arch/arm/mach-socfpga/mailbox_s10.c
> +++ b/arch/arm/mach-socfpga/mailbox_s10.c
> @@ -221,9 +221,7 @@ static __always_inline int
> mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect,
>  			if ((MBOX_RESP_CLIENT_GET(resp) ==
>  			     MBOX_CLIENT_ID_UBOOT) &&
>  			    (MBOX_RESP_ID_GET(resp) == id)) {
> -				ret = MBOX_RESP_ERR_GET(resp);
> -				if (ret)
> -					return ret;
> +				int resp_err = MBOX_RESP_ERR_GET(resp);
> 
>  				if (resp_buf_len) {
>  					buf_len = *resp_buf_len;
> @@ -252,7 +250,7 @@ static __always_inline int
> mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect,
>  						buf_len--;
>  					}
>  				}
> -				return ret;
> +				return resp_err;
>  			}
>  		}
>  	};


Reviewed-by: Ley Foon Tan <ley.foon.tan@intel.com>
diff mbox series

Patch

diff --git a/arch/arm/mach-socfpga/mailbox_s10.c b/arch/arm/mach-socfpga/mailbox_s10.c
index 729d9b04fa..e8a587f007 100644
--- a/arch/arm/mach-socfpga/mailbox_s10.c
+++ b/arch/arm/mach-socfpga/mailbox_s10.c
@@ -221,9 +221,7 @@  static __always_inline int mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect,
 			if ((MBOX_RESP_CLIENT_GET(resp) ==
 			     MBOX_CLIENT_ID_UBOOT) &&
 			    (MBOX_RESP_ID_GET(resp) == id)) {
-				ret = MBOX_RESP_ERR_GET(resp);
-				if (ret)
-					return ret;
+				int resp_err = MBOX_RESP_ERR_GET(resp);
 
 				if (resp_buf_len) {
 					buf_len = *resp_buf_len;
@@ -252,7 +250,7 @@  static __always_inline int mbox_send_cmd_common(u8 id, u32 cmd, u8 is_indirect,
 						buf_len--;
 					}
 				}
-				return ret;
+				return resp_err;
 			}
 		}
 	};