Skip to contentSkip to conversation

cxlflash: shift wrapping bug in afu_link_reset()

PATCH In review Dan Carpenter 3 participants 3 messages Aug 18, 2015

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

PATCH 1/1 cxlflash: shift wrapping bug in afu_link_reset()

"port_sel" is a u64 so the shifting should also be a 64 bit shift.

Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
drivers/scsi/cxlflash/main.c +2 -2
index 0720d2f..f97421d 100644
@@ -1179,7 +1179,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 
 	/* first switch the AFU to the other links, if any */
 	port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel);
-	port_sel &= ~(1 << port);
+	port_sel &= ~(1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
 
@@ -1196,7 +1196,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 		       __func__, port);
 
 	/* switch back to include this port */
-	port_sel |= (1 << port);
+	port_sel |= (1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 28 lines · Dan Carpenter

"port_sel" is a u64 so the shifting should also be a 64 bit shift.

Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
drivers/scsi/cxlflash/main.c +2 -3
index 0720d2f..f97421d 100644
@@ -1179,7 +1179,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 
 	/* first switch the AFU to the other links, if any */
 	port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel);
-	port_sel &= ~(1 << port);
+	port_sel &= ~(1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
 
@@ -1196,7 +1196,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 		       __func__, port);
 
 	/* switch back to include this port */
-	port_sel |= (1 << port);
+	port_sel |= (1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
 
--
Quoted 3 lines

To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 6 lines
Johannes Thumshirn                                           Storage
[email protected]                                 +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600  D0D0 0393 969D 2D76 0850
Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 21 lines · Dan Carpenter

"port_sel" is a u64 so the shifting should also be a 64 bit shift.

Fixes c21e0bbfc485 ('cxlflash: Base support for IBM CXL Flash Adapter')
drivers/scsi/cxlflash/main.c +1 -1
index 0720d2f..f97421d 100644
@@ -1179,7 +1179,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 
 	/* first switch the AFU to the other links, if any */
 	port_sel = readq_be(&afu->afu_map->global.regs.afu_port_sel);
-	port_sel &= ~(1 << port);
+	port_sel &= ~(1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);
 

drivers/scsi/cxlflash/main.c static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs) · line 1202

Quoted 8 lines
drivers/scsi/cxlflash/main.c +1 -1
@@ -1196,7 +1196,7 @@ static void afu_link_reset(struct afu *afu, int port, u64 *fc_regs)
 		       __func__, port);
 
 	/* switch back to include this port */
-	port_sel |= (1 << port);
+	port_sel |= (1ULL << port);
 	writeq_be(port_sel, &afu->afu_map->global.regs.afu_port_sel);
 	cxlflash_afu_sync(afu, 0, 0, AFU_GSYNC);