Skip to contentSkip to conversation

pata_legacy: bogus clock in opti82c46x_set_piomode()

PATCH In review Dan Carpenter 2 participants 2 messages Mar 11, 2013 – Apr 3, 2013

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

PATCH 1/1 pata_legacy: bogus clock in opti82c46x_set_piomode()

"sysclk" is used as an index into a 4 element array. My static checker complains because it can be out of bounds. From the context, it looks like there is a right bit shift missing.

---
I don't have the hardware to test this.

drivers/ata/pata_legacy.c +1 -1
index 4fe9d21..be81642 100644
@@ -542,7 +542,7 @@ static void opti82c46x_set_piomode(struct ata_port *ap, struct ata_device *adev)
 	u8 sysclk;
 
 	/* Get the clock */
-	sysclk = opti_syscfg(0xAC) & 0xC0;	/* BIOS set */
+	sysclk = (opti_syscfg(0xAC) & 0xC0) >> 6;	/* BIOS set */
 
 	/* Enter configuration mode */
 	ioread16(ap->ioaddr.error_addr);
#1 lore raw
Quoted 7 lines · Dan Carpenter

"sysclk" is used as an index into a 4 element array. My static checker complains because it can be out of bounds. From the context, it looks like there is a right bit shift missing.

---
I don't have the hardware to test this.

applied (to #upstream)