Skip to contentSkip to conversation

fsl/sata: correctly identify failed malloc

PATCH New Heinrich Schuchardt 2 participants 3 messages Apr 15, 2017 – Apr 19, 2017 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fsl/sata: correctly identify failed malloc

After allocating sata->cmd_hdr_tbl_offset we have to check this variable and not variable sata.

The problem was indicated by cppcheck.

---
 drivers/block/fsl_sata.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/block/fsl_sata.c +1 -1
index e000ebff76..31f7fab8b4 100644
@@ -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;
 	}
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/1 fsl/sata: correctly identify failed malloc

Quoted 6 lines · Heinrich Schuchardt

After allocating sata->cmd_hdr_tbl_offset we have to check this variable and not variable sata.

The problem was indicated by cppcheck.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170415/91b75bd1/attachment.sig>
#2 lore raw

PATCH 1/1 fsl/sata: correctly identify failed malloc

In reply to Heinrich Schuchardt
Quoted 7 lines · xypron.glpk at gmx.de

After allocating sata->cmd_hdr_tbl_offset we have to check this variable and not variable sata.

The problem was indicated by cppcheck.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170419/1187cea9/attachment.sig>