Skip to contentSkip to conversation

dma: cppi41: off by one in desc_to_chan()

PATCH In review Dan Carpenter 3 participants 4 messages Aug 23, 2013 – Aug 28, 2013

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

PATCH 1/1 dma: cppi41: off by one in desc_to_chan()

The test here should be ">=" instead of ">". The cdd->chan_busy[] array has "ALLOC_DECS_NUM" elements.

drivers/dma/cppi41.c +1 -1
index 5dcebca..7f6524c 100644
@@ -241,7 +241,7 @@ static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc)
 	}
 
 	desc_num = (desc - cdd->descs_phys) / sizeof(struct cppi41_desc);
-	BUG_ON(desc_num > ALLOC_DECS_NUM);
+	BUG_ON(desc_num >= ALLOC_DECS_NUM);
 	c = cdd->chan_busy[desc_num];
 	cdd->chan_busy[desc_num] = NULL;
 	return c;
#1 lore raw
Quoted 4 lines · Dan Carpenter

The test here should be ">=" instead of ">". The cdd->chan_busy[] array has "ALLOC_DECS_NUM" elements.

This needs to go thru USB tree

Acked-by Vinod Koul <[email protected]>

~Vinod

Quoted 14 lines
drivers/dma/cppi41.c +1 -1
index 5dcebca..7f6524c 100644
@@ -241,7 +241,7 @@ static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc)
 	}
 
 	desc_num = (desc - cdd->descs_phys) / sizeof(struct cppi41_desc);
-	BUG_ON(desc_num > ALLOC_DECS_NUM);
+	BUG_ON(desc_num >= ALLOC_DECS_NUM);
 	c = cdd->chan_busy[desc_num];
 	cdd->chan_busy[desc_num] = NULL;
 	return c;
#2 lore raw

PATCH 1/1 dma: cppi41: off by one in desc_to_chan()

The test here should be ">=" instead of ">". The cdd->chan_busy[] array has "ALLOC_DECS_NUM" elements.

---
Resending to Greg and the USB people because Vinod says this goes through the USB tree.

drivers/dma/cppi41.c +1 -1
index 5dcebca..7f6524c 100644
@@ -241,7 +241,7 @@ static struct cppi41_channel *desc_to_chan(struct cppi41_dd *cdd, u32 desc)
 	}
 
 	desc_num = (desc - cdd->descs_phys) / sizeof(struct cppi41_desc);
-	BUG_ON(desc_num > ALLOC_DECS_NUM);
+	BUG_ON(desc_num >= ALLOC_DECS_NUM);
 	c = cdd->chan_busy[desc_num];
 	cdd->chan_busy[desc_num] = NULL;
 	return c;