mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-09-03 10:33:11 +02:00
wifi: airo: do not assign -1 to unsigned char
With char becoming unsigned by default, and with `char` alone being ambiguous and based on architecture, we get a warning when assigning the unchecked output of hex_to_bin() to that unsigned char. Mark `key` as a `u8`, which matches the struct's type, and then check each call to hex_to_bin() before casting. Cc: Kalle Valo <kvalo@kernel.org> Cc: linux-wireless@vger.kernel.org Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Signed-off-by: Kalle Valo <kvalo@kernel.org> Link: https://lore.kernel.org/r/20221024162843.535921-1-Jason@zx2c4.com
This commit is contained in:
parent
69188df5f6
commit
e6cb876945
|
@ -5232,7 +5232,7 @@ static int get_wep_tx_idx(struct airo_info *ai)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_wep_key(struct airo_info *ai, u16 index, const char *key,
|
static int set_wep_key(struct airo_info *ai, u16 index, const u8 *key,
|
||||||
u16 keylen, int perm, int lock)
|
u16 keylen, int perm, int lock)
|
||||||
{
|
{
|
||||||
static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
|
static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 };
|
||||||
|
@ -5283,7 +5283,7 @@ static void proc_wepkey_on_close(struct inode *inode, struct file *file)
|
||||||
struct net_device *dev = pde_data(inode);
|
struct net_device *dev = pde_data(inode);
|
||||||
struct airo_info *ai = dev->ml_priv;
|
struct airo_info *ai = dev->ml_priv;
|
||||||
int i, rc;
|
int i, rc;
|
||||||
char key[16];
|
u8 key[16];
|
||||||
u16 index = 0;
|
u16 index = 0;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
|
@ -5311,12 +5311,22 @@ static void proc_wepkey_on_close(struct inode *inode, struct file *file)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) {
|
for (i = 0; i < 16*3 && data->wbuffer[i+j]; i++) {
|
||||||
|
int val;
|
||||||
|
|
||||||
|
if (i % 3 == 2)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
val = hex_to_bin(data->wbuffer[i+j]);
|
||||||
|
if (val < 0) {
|
||||||
|
airo_print_err(ai->dev->name, "WebKey passed invalid key hex");
|
||||||
|
return;
|
||||||
|
}
|
||||||
switch(i%3) {
|
switch(i%3) {
|
||||||
case 0:
|
case 0:
|
||||||
key[i/3] = hex_to_bin(data->wbuffer[i+j])<<4;
|
key[i/3] = (u8)val << 4;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
key[i/3] |= hex_to_bin(data->wbuffer[i+j]);
|
key[i/3] |= (u8)val;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user