summaryrefslogtreecommitdiff
path: root/drivers/spi
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2019-01-23 15:00:22 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-01-27 16:50:14 +0300
commit72c50d87f76326e1bd3c1081d09ef25aad243586 (patch)
tree86a72d0d4c8c46d2408eaaf233afffb1f63d7e71 /drivers/spi
parent5c2d0191c6c574d84cfa83b1bee73a7e4baccfc6 (diff)
downloadlinux-72c50d87f76326e1bd3c1081d09ef25aad243586.tar.xz
spi/topcliff_pch: Fix potential NULL dereference on allocation error
[ Upstream commit e902cdcb5112b89ee445588147964723fd69ffb4 ] In pch_spi_handle_dma, it doesn't check for NULL returns of kcalloc so it would result in an Oops. Fixes: c37f3c2749b5 ("spi/topcliff_pch: DMA support") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-topcliff-pch.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/spi/spi-topcliff-pch.c b/drivers/spi/spi-topcliff-pch.c
index 4389ab80c23e..fa730a871d25 100644
--- a/drivers/spi/spi-topcliff-pch.c
+++ b/drivers/spi/spi-topcliff-pch.c
@@ -1008,6 +1008,9 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
/* RX */
dma->sg_rx_p = kcalloc(num, sizeof(*dma->sg_rx_p), GFP_ATOMIC);
+ if (!dma->sg_rx_p)
+ return;
+
sg_init_table(dma->sg_rx_p, num); /* Initialize SG table */
/* offset, length setting */
sg = dma->sg_rx_p;
@@ -1068,6 +1071,9 @@ static void pch_spi_handle_dma(struct pch_spi_data *data, int *bpw)
}
dma->sg_tx_p = kcalloc(num, sizeof(*dma->sg_tx_p), GFP_ATOMIC);
+ if (!dma->sg_tx_p)
+ return;
+
sg_init_table(dma->sg_tx_p, num); /* Initialize SG table */
/* offset, length setting */
sg = dma->sg_tx_p;