mirror of
https://github.com/torvalds/linux.git
synced 2026-06-08 14:42:37 +02:00
spi/topcliff_pch: Fix potential NULL dereference on allocation error
[ Upstream commite902cdcb51] In pch_spi_handle_dma, it doesn't check for NULL returns of kcalloc so it would result in an Oops. Fixes:c37f3c2749("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>
This commit is contained in:
parent
5c2d0191c6
commit
72c50d87f7
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user