fix uvm fault in athn_clock_rate

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

fix uvm fault in athn_clock_rate

Stefan Sperling-5
I got this uvm fault after typing 'ifconfig athn0 mediaopt monitor'
after boot, as the first ifconfig command to the athn driver.

Fix below. Note that IEEE80211_CHAN_ANYC is 0xffff (in %rax).

uvm_fault(0xffffff011c437e00, 0x10002, 0, 1) -> e
kernel: page fault trap, code=0
Stopped at      athn_clock_rate+0x1f:   testb   $0x1,0x3(%rax)
ddb{0}> trace
athn_clock_rate(ffff8000006ff000,ffffff0009490910,ffffff0001c3c010,ffffff0001c3
c010,10,ffff80002216a7c0) at athn_clock_rate+0x1f
athn_updateslot(ffff8000006ff048,0,100400,ffff8000006ff048,0,ffffff0009490880) a
t athn_updateslot+0x35
ieee80211_reset_erp(ffff8000006ff048,1,ffff8000006ff048,ffffff011dfdec80,ffffff
ff81316094,ffff80002216a8e0) at ieee80211_reset_erp+0x44
ieee80211_media_change(ffff8000006ff048,0,0,ffff8000006ff048,100400,ffff8000006
ff000) at ieee80211_media_change+0x210
athn_media_change(ffff8000006ff048,100400,ffff8000006ff048,ffff8000006ffa98,fff
f8000006ffa98,1) at athn_media_change+0x1f
ifmedia_ioctl(ffff8000006ff048,ffff80002216ad60,ffff8000006ffa98,c0206937,5,fff
f80002216ad60) at ifmedia_ioctl+0x149
ieee80211_ioctl(ffff8000006ff048,c0206937,ffff80002216ad60,ffff80002216ab60,5,f
fff8000006ff000) at ieee80211_ioctl+0x553
athn_ioctl(ffff8000006ff048,c0206937,ffff80002216ad60,c0206937,ffffff011afc1648
,ffff80002216ad60) at athn_ioctl+0x79
ifioctl(ffffff011afc1648,c0206937,ffff80002216ad60,ffff8000220f9880,ffff8000220
f9880,ffff80002216ad60) at ifioctl+0x3f2
soo_ioctl(ffffff011d463638,c0206937,ffff80002216ad60,ffff8000220f9880,ffff80002
20f9880,ffff80002216ae60) at soo_ioctl+0x208
sys_ioctl(ffff8000220f9880,ffff80002216ae60,ffff80002216aeb0,3,36,1) at sys_ioc
tl+0x1c1
syscall() at syscall+0x29f
--- syscall (number 54) ---
end of kernel
end trace frame: 0x1ac7d7a56ac0, count: -12
0x1ac7d781b18a:
ddb{0}> show reg
rdi               0xffff8000006ff000
rsi                                0
rbp               0xffff80002216a7e0
rbx                             0x14
rdx                                0
rcx                              0x8
rax                           0xffff    __ALIGN_SIZE+0xefff
r8                 0x101010101010101
r9                0xffff8000006ff048
r10                              0x6
r11               0xffffffff810b2e20    athn_updateslot
r12               0xffff8000006ff000
r13                       0xffffffff
r14                              0x8
r15                                0
rip               0xffffffff810b2b0f    athn_clock_rate+0x1f
cs                               0x8
rflags                       0x10286    mptramp_longmode+0x1de
rsp               0xffff80002216a7c0
ss                              0x10
athn_clock_rate+0x1f:   testb   $0x1,0x3(%rax)
ddb{0}>

Index: athn.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/athn.c,v
retrieving revision 1.96
diff -u -p -r1.96 athn.c
--- athn.c 17 Jan 2017 20:07:39 -0000 1.96
+++ athn.c 17 May 2017 18:55:55 -0000
@@ -2597,7 +2597,8 @@ athn_clock_rate(struct athn_softc *sc)
  struct ieee80211com *ic = &sc->sc_ic;
  int clockrate; /* MHz. */
 
- if (IEEE80211_IS_CHAN_5GHZ(ic->ic_bss->ni_chan)) {
+ if (ic->ic_bss->ni_chan != IEEE80211_CHAN_ANYC &&
+    IEEE80211_IS_CHAN_5GHZ(ic->ic_bss->ni_chan)) {
  if (sc->flags & ATHN_FLAG_FAST_PLL_CLOCK)
  clockrate = AR_CLOCK_RATE_FAST_5GHZ_OFDM;
  else