Skip to contentSkip to conversation

cxgb4: potential shift wrapping bug

PATCH Superseded Dan Carpenter 1 participant 1 message Oct 2, 2014

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cxgb4: potential shift wrapping bug

"cntxt_id" is an unsigned int but "udb" is a u64 so there is a potential shift wrapping bug here.

drivers/net/ethernet/chelsio/cxgb4/sge.c +1 -1
index bb7851e..e8e90ce 100644
@@ -2258,7 +2258,7 @@ static u64 udb_address(struct adapter *adap, unsigned int cntxt_id,
 		(QUEUESPERPAGEPF1 - QUEUESPERPAGEPF0) * adap->fn);
 	udb_density = 1 << ((qpp >> s_qpp) & QUEUESPERPAGEPF0_MASK);
 	qpshift = PAGE_SHIFT - ilog2(udb_density);
-	udb = cntxt_id << qpshift;
+	udb = (u64)cntxt_id << qpshift;
 	udb &= PAGE_MASK;
 	page = udb / PAGE_SIZE;
 	udb += (cntxt_id - (page * udb_density)) * SGE_UDB_SIZE;