]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
fsl/sata: correctly identify failed malloc
authorxypron.glpk@gmx.de <xypron.glpk@gmx.de>
Sat, 15 Apr 2017 13:31:53 +0000 (15:31 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 18 Apr 2017 14:29:24 +0000 (10:29 -0400)
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>
drivers/block/fsl_sata.c

index e000ebff76f5da575c60010eaf5582d3c886e519..31f7fab8b47aaae1fdc6dda5001a123506250053 100644 (file)
@@ -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;
        }