Skip to contentSkip to conversation

dmaengine: xgene: buffer overflow in xgene_dma_init_channels()

PATCH Applied Dan Carpenter 2 participants 2 messages Apr 9, 2015 – Apr 17, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 dmaengine: xgene: buffer overflow in xgene_dma_init_channels()

We put 9 characters into the 8 character name[] array. Let's make the array bigger and change the sprintf() to snprintf().

drivers/dma/xgene-dma.c +2 -2
index aa61935..06d4042 100755
@@ -314,7 +314,7 @@ struct xgene_dma_chan {
 	struct device *dev;
 	int id;
 	int rx_irq;
-	char name[8];
+	char name[10];
 	spinlock_t lock;
 	int pending;
 	int max_outstanding;
@@ -1876,7 +1876,7 @@ static void xgene_dma_init_channels(struct xgene_dma *pdma)
 		chan->dev = pdma->dev;
 		chan->pdma = pdma;
 		chan->id = i;
-		sprintf(chan->name, "dmachan%d", chan->id);
+		snprintf(chan->name, sizeof(chan->name), "dmachan%d", chan->id);
 	}
 }
 
Applied
#1 lore raw
Quoted 3 lines · Dan Carpenter

We put 9 characters into the 8 character name[] array. Let's make the array bigger and change the sprintf() to snprintf().

Applied, both

Thanks

Signature · 1 line
~Vinod