Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rt2x00: Fix HW crypto key handling

When a crypto key is being removed, rt2x00mac should not
reset the key->hw_key_idx value because that will prevent
the driver from removing the correct key from the hardware.

Furthermore ffz() starts counting at 0 instead of 1, so we don't
need to substract 1 from the resulting value.

Signed-off-by: Stephen Blackheath <tramp.enshrine.stephen@blacksapphire.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Ivo van Doorn and committed by
John W. Linville
acaf908d 4492bea6

+6 -5
+2 -1
drivers/net/wireless/rt2x00/rt2x00mac.c
··· 543 543 * provided but key 0 is not, then the key is not found 544 544 * by the hardware during RX). 545 545 */ 546 - key->hw_key_idx = 0; 546 + if (cmd == SET_KEY) 547 + key->hw_key_idx = 0; 547 548 548 549 if (key->flags & IEEE80211_KEY_FLAG_PAIRWISE) 549 550 set_key = rt2x00dev->ops->lib->config_pairwise_key;
+2 -2
drivers/net/wireless/rt2x00/rt61pci.c
··· 381 381 if (reg && reg == mask) 382 382 return -ENOSPC; 383 383 384 - key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 384 + key->hw_key_idx += reg ? ffz(reg) : 0; 385 385 386 386 /* 387 387 * Upload key to hardware ··· 477 477 return -ENOSPC; 478 478 } 479 479 480 - key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 480 + key->hw_key_idx += reg ? ffz(reg) : 0; 481 481 482 482 /* 483 483 * Upload key to hardware
+2 -2
drivers/net/wireless/rt2x00/rt73usb.c
··· 393 393 if (reg && reg == mask) 394 394 return -ENOSPC; 395 395 396 - key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 396 + key->hw_key_idx += reg ? ffz(reg) : 0; 397 397 398 398 /* 399 399 * Upload key to hardware ··· 494 494 return -ENOSPC; 495 495 } 496 496 497 - key->hw_key_idx += reg ? (ffz(reg) - 1) : 0; 497 + key->hw_key_idx += reg ? ffz(reg) : 0; 498 498 499 499 /* 500 500 * Upload key to hardware