Skip to contentSkip to conversation

dmaengine: pl330: Initialize pl330 for pl330_prep_dma_memcpy after NULL check of pch

PATCH Applied Maninder Singh 2 participants 2 messages May 25, 2015 dmaengine

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dmaengine: pl330: Initialize pl330 for pl330_prep_dma_memcpy after NULL check of pch

From: Maninder Singh <[email protected]>

Currently pch pointer is already dereferenced before NULL check and thus we are getting below warning:
warn: variable dereferenced before check 'pch'

So initialize struct pl330_dmac *pl330 after NULL check of dma_pl330_chan *pch.

---
 drivers/dma/pl330.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/dma/pl330.c +3 -1
index a7d9d30..7e27144 100644
@@ -2581,12 +2581,14 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
 {
 	struct dma_pl330_desc *desc;
 	struct dma_pl330_chan *pch = to_pchan(chan);
-	struct pl330_dmac *pl330 = pch->dmac;
+	struct pl330_dmac *pl330;
 	int burst;
 
 	if (unlikely(!pch || !len))
 		return NULL;
 
+	pl330 = pch->dmac;
+
 	desc = __pl330_prep_dma_memcpy(pch, dst, src, len);
 	if (!desc)
 		return NULL;
Signature · 1 line
1.7.1
Applied
#1 lore raw
Quoted 9 lines · Maninder Singh

From: Maninder Singh <[email protected]>

Currently pch pointer is already dereferenced before NULL check and thus we are getting below warning:
warn: variable dereferenced before check 'pch'

So initialize struct pl330_dmac *pl330 after NULL check of dma_pl330_chan *pch.

Applied, thanks

Signature · 1 line
~Vinod
Quoted 27 lines
---
 drivers/dma/pl330.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
drivers/dma/pl330.c +3 -1
index a7d9d30..7e27144 100644
@@ -2581,12 +2581,14 @@ pl330_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
 {
 	struct dma_pl330_desc *desc;
 	struct dma_pl330_chan *pch = to_pchan(chan);
-	struct pl330_dmac *pl330 = pch->dmac;
+	struct pl330_dmac *pl330;
 	int burst;
 
 	if (unlikely(!pch || !len))
 		return NULL;
 
+	pl330 = pch->dmac;
+
 	desc = __pl330_prep_dma_memcpy(pch, dst, src, len);
 	if (!desc)
 		return NULL;
Signature · 1 line
1.7.1