Skip to contentSkip to conversation

fix for integer overflow in hd6457[02] driver code

PATCH New Krzysztof Halasa 1 participant 1 message Sep 5, 2004

Subsystems (3)
lore
Share & tools
lore

Krzysztof Halasa

author maintainer
#0 lore raw

PATCH 1/1 fix for integer overflow in hd6457[02] driver code

Hi,

The attached patch fixes an integer overflow in drivers for N2, C101, PCI200SYN WAN cards (brv * port->settings.clock_rate overflowed at requested clock rate of 8*1024*1024 bps, problem noted by Nagaraj Kanniah).

Please apply to 2.4 and 2.6 kernel trees. Thanks.

[now the patch has made it here]

Signature · 1 line
Krzysztof Halasa
drivers/net/wan/hd6457x.c +3 -3
@@ -463,8 +463,8 @@
 			brv >>= 1; /* brv = 2^9 = 512 max in specs */
 
 			/* Baud Rate = CLOCK_BASE / TMC / 2^BR */
-			tmc = CLOCK_BASE / (brv * port->settings.clock_rate);
-		}while(br > 1 && tmc <= 128);
+			tmc = CLOCK_BASE / brv / port->settings.clock_rate;
+		}while (br > 1 && tmc <= 128);
 
 		if (tmc < 1) {
 			tmc = 1;
@@ -473,7 +473,7 @@
 		} else if (tmc > 255)
 			tmc = 256; /* tmc=0 means 256 - low baud rates */
 
-		port->settings.clock_rate = CLOCK_BASE / (brv * tmc);
+		port->settings.clock_rate = CLOCK_BASE / brv / tmc;
 	} else {
 		br = 9; /* Minimum clock rate */
 		tmc = 256;	/* 8bit = 0 */