diff mbox

[U-Boot,1/1] fsl/sata: correctly identify failed malloc

Message ID 20170415133153.26062-1-xypron.glpk@gmx.de
State Accepted
Commit 7a931b958e4f942b16d3f5d31dc4c0982fa186c8
Delegated to: Tom Rini
Headers show

Commit Message

Heinrich Schuchardt April 15, 2017, 1:31 p.m. UTC
After allocating sata->cmd_hdr_tbl_offset we have to check
this variable and not variable sata.

The problem was indicated by cppcheck.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 drivers/block/fsl_sata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tom Rini April 15, 2017, 4:12 p.m. UTC | #1
On Sat, Apr 15, 2017 at 03:31:53PM +0200, Heinrich Schuchardt wrote:

> After allocating sata->cmd_hdr_tbl_offset we have to check
> this variable and not variable sata.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini April 19, 2017, 1:04 p.m. UTC | #2
On Sat, Apr 15, 2017 at 03:31:53PM +0200, xypron.glpk@gmx.de wrote:

> After allocating sata->cmd_hdr_tbl_offset we have to check
> this variable and not variable sata.
> 
> The problem was indicated by cppcheck.
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/drivers/block/fsl_sata.c b/drivers/block/fsl_sata.c
index e000ebff76..31f7fab8b4 100644
--- a/drivers/block/fsl_sata.c
+++ b/drivers/block/fsl_sata.c
@@ -124,7 +124,7 @@  int init_sata(int dev)
 	length = sizeof(struct cmd_hdr_tbl);
 	align = SATA_HC_CMD_HDR_TBL_ALIGN;
 	sata->cmd_hdr_tbl_offset = (void *)malloc(length + align);
-	if (!sata) {
+	if (!sata->cmd_hdr_tbl_offset) {
 		printf("alloc the command header failed\n\r");
 		return -1;
 	}