Skip to contentSkip to conversation

Staging: rtl8192su: off by one checks

PATCH New Dan Carpenter 1 participant 1 message Aug 10, 2010

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

PATCH 1/1 Staging: rtl8192su: off by one checks

The comparison here should be >= ARRAY_SIZE() instead of > ARRAY_SIZE().

drivers/staging/rtl8192su/r8192S_Efuse.c +2 -4
index bbefd0f..7eaa686 100644
@@ -1989,9 +1989,8 @@ void efuse_read_data(struct net_device* dev,u8 efuse_read_item,u8 *data,u32 data
 	u8 tmpidx;
 	u8 pg_data[8];
 
-	if(efuse_read_item>  (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
+	if (efuse_read_item >= ARRAY_SIZE(RTL8712_SDIO_EFUSE_TABLE))
 		return ;
-	}
 
 	offset		= RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].offset ;
 	word_start	= RTL8712_SDIO_EFUSE_TABLE[efuse_read_item].word_start;
@@ -2042,9 +2041,8 @@ void efuse_write_data(struct net_device* dev,u8 efuse_write_item,u8 *data,u32 da
 	u8 tmpidx,tmpbitmask;
 	u8 pg_data[8],tmpbytes=0;
 
-	if(efuse_write_item>  (sizeof(RTL8712_SDIO_EFUSE_TABLE)/sizeof(EFUSE_MAP))){
+	if (efuse_write_item >=  ARRAY_SIZE(RTL8712_SDIO_EFUSE_TABLE))
 		return ;
-	}
 
 	offset		= RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].offset ;
 	word_start	= RTL8712_SDIO_EFUSE_TABLE[efuse_write_item].word_start;