Skip to content

Commit

Permalink
ata: ahci: fix memory leak
Browse files Browse the repository at this point in the history
malloc(..) and memalign(..) are both allocating memory and as a result
we leak the memory allocated with malloc(..).

Signed-off-by: Christian Gmeiner <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
  • Loading branch information
austriancoder authored and trini committed May 9, 2019
1 parent 3a90b50 commit 28b4ba9
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions drivers/ata/ahci.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,15 +571,12 @@ static int ahci_port_start(struct ahci_uc_priv *uc_priv, u8 port)
return -1;
}

mem = malloc(AHCI_PORT_PRIV_DMA_SZ + 2048);
mem = memalign(2048, AHCI_PORT_PRIV_DMA_SZ);
if (!mem) {
free(pp);
printf("%s: No mem for table!\n", __func__);
return -ENOMEM;
}

/* Aligned to 2048-bytes */
mem = memalign(2048, AHCI_PORT_PRIV_DMA_SZ);
memset(mem, 0, AHCI_PORT_PRIV_DMA_SZ);

/*
Expand Down

0 comments on commit 28b4ba9

Please sign in to comment.