aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-12-27 10:26:00 +0100
committerTom Rini <trini@konsulko.com>2021-01-18 15:23:06 -0500
commit4908067b8f87ebaa9a26514dfe5a9ffba13deb2c (patch)
tree39741bbaf08f42eb20e30b81f44be02058295864
parent9e9a530a61c01e412a239d8c211d5b1e26b578fa (diff)
downloadu-boot-4908067b8f87ebaa9a26514dfe5a9ffba13deb2c.zip
u-boot-4908067b8f87ebaa9a26514dfe5a9ffba13deb2c.tar.gz
u-boot-4908067b8f87ebaa9a26514dfe5a9ffba13deb2c.tar.bz2
dma: bcm6348: incorrect buffer allocation
Calling calloc() for 0 members does not make any sense. Setting ch_priv->busy_desc = NULL for ch_priv->desc_cnt > 0 is equally unreasonable. The current code will lead to a NULL dereference in bcm6348_iudma_enable(). The assignments for ch_priv->busy_desc are obviously swapped. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
-rw-r--r--drivers/dma/bcm6348-iudma.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/dma/bcm6348-iudma.c b/drivers/dma/bcm6348-iudma.c
index 9857760..c04aa55 100644
--- a/drivers/dma/bcm6348-iudma.c
+++ b/drivers/dma/bcm6348-iudma.c
@@ -313,10 +313,10 @@ static int bcm6348_iudma_request(struct dma *dma)
ch_priv->desc_id = 0;
if (bcm6348_iudma_chan_is_rx(dma->id)) {
ch_priv->desc_cnt = 0;
- ch_priv->busy_desc = calloc(ch_priv->desc_cnt, sizeof(bool));
+ ch_priv->busy_desc = NULL;
} else {
ch_priv->desc_cnt = ch_priv->dma_ring_size;
- ch_priv->busy_desc = NULL;
+ ch_priv->busy_desc = calloc(ch_priv->desc_cnt, sizeof(bool));
}
return 0;