mirror of
https://github.com/fail0verflow/switch-linux.git
synced 2025-05-04 02:34:21 -04:00
dma: ste_dma40: Fix potential null pointer dereference
kcalloc can return NULL. Check the pointer before dereferencing. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
This commit is contained in:
parent
cbbe13ea09
commit
2ec7e2e7b5
1 changed files with 3 additions and 0 deletions
|
@ -2591,6 +2591,9 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT);
|
sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT);
|
||||||
|
if (!sg)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
for (i = 0; i < periods; i++) {
|
for (i = 0; i < periods; i++) {
|
||||||
sg_dma_address(&sg[i]) = dma_addr;
|
sg_dma_address(&sg[i]) = dma_addr;
|
||||||
sg_dma_len(&sg[i]) = period_len;
|
sg_dma_len(&sg[i]) = period_len;
|
||||||
|
|
Loading…
Add table
Reference in a new issue