Skip to contentSkip to conversation

Staging: rtl8192e: off by one in rtl8192_get_channel_map()

PATCH In review Dan Carpenter 2 participants 3 messages Sep 21, 2011

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

PATCH 1/1 Staging: rtl8192e: off by one in rtl8192_get_channel_map()

COUNTRY_CODE_MAX is not a valid country code. We're off by one here. This gets passed to Dot11d_Channelmap() where it's used as an offset into the ChannelPlan[] array.

drivers/staging/rtl8192e/rtl_core.c +1 -1
index 6530058..1beb04f 100644
@@ -1308,7 +1308,7 @@ static short rtl8192_get_channel_map(struct net_device *dev)
 		return -1;
 	}
 
-	if (priv->ChannelPlan > COUNTRY_CODE_MAX) {
+	if (priv->ChannelPlan >= COUNTRY_CODE_MAX) {
 		printk(KERN_INFO "rtl819x_init:Error channel plan! Set to "
 		       "default.\n");
 		priv->ChannelPlan = COUNTRY_CODE_FCC;
#1 lore raw
Quoted 5 lines · Dan Carpenter

COUNTRY_CODE_MAX is not a valid country code. We're off by one here. This gets passed to Dot11d_Channelmap() where it's used as an offset into the ChannelPlan[] array.

Dan, good catch. Did this cause a problem, or did you find it while reading the code?

Larry

Quoted 15 lines
drivers/staging/rtl8192e/rtl_core.c +1 -1
index 6530058..1beb04f 100644
@@ -1308,7 +1308,7 @@ static short rtl8192_get_channel_map(struct net_device *dev)
  		return -1;
  	}
 
-	if (priv->ChannelPlan>  COUNTRY_CODE_MAX) {
+	if (priv->ChannelPlan>= COUNTRY_CODE_MAX) {
  		printk(KERN_INFO "rtl819x_init:Error channel plan! Set to "
  		       "default.\n");
  		priv->ChannelPlan = COUNTRY_CODE_FCC;