Module Name: src Committed By: skrll Date: Sat Sep 23 14:27:44 UTC 2017
Modified Files: src/sys/dev/usb: if_athn_usb.c Log Message: PR/52553 Panic on "ifconfig athn0 up" Don't race for a transfer in athn_usb_init on the free list for beacons. Instead pre-assign a transfer to beacons in athn_usb_alloc_tx_list To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/dev/usb/if_athn_usb.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/if_athn_usb.c diff -u src/sys/dev/usb/if_athn_usb.c:1.22 src/sys/dev/usb/if_athn_usb.c:1.23 --- src/sys/dev/usb/if_athn_usb.c:1.22 Thu Jun 1 02:45:11 2017 +++ src/sys/dev/usb/if_athn_usb.c Sat Sep 23 14:27:44 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: if_athn_usb.c,v 1.22 2017/06/01 02:45:11 chs Exp $ */ +/* $NetBSD: if_athn_usb.c,v 1.23 2017/09/23 14:27:44 skrll Exp $ */ /* $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $ */ /*- @@ -22,7 +22,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.22 2017/06/01 02:45:11 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.23 2017/09/23 14:27:44 skrll Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -728,9 +728,15 @@ athn_usb_alloc_tx_list(struct athn_usb_s /* Append this Tx buffer to our free list. */ TAILQ_INSERT_TAIL(&usc->usc_tx_free_list, data, next); } - if (error != 0) + if (error == 0) { + /* Steal one buffer for beacons. */ + usc->usc_tx_bcn = TAILQ_FIRST(&usc->usc_tx_free_list); + TAILQ_REMOVE(&usc->usc_tx_free_list, usc->usc_tx_bcn, next); + } else { athn_usb_free_tx_list(usc); + } mutex_exit(&usc->usc_tx_mtx); + return error; } @@ -749,6 +755,10 @@ athn_usb_free_tx_list(struct athn_usb_so if (xfer != NULL) usbd_destroy_xfer(xfer); } + if (usc->usc_tx_bcn) { + usbd_destroy_xfer(usc->usc_tx_bcn->xfer); + usc->usc_tx_bcn = NULL; + } } Static int @@ -2756,12 +2766,6 @@ athn_usb_init_locked(struct ifnet *ifp) usc->usc_cmdq.cur = usc->usc_cmdq.next = usc->usc_cmdq.queued = 0; mutex_spin_exit(&usc->usc_task_mtx); - /* Steal one buffer for beacons. */ - mutex_enter(&usc->usc_tx_mtx); - usc->usc_tx_bcn = TAILQ_FIRST(&usc->usc_tx_free_list); - TAILQ_REMOVE(&usc->usc_tx_free_list, usc->usc_tx_bcn, next); - mutex_exit(&usc->usc_tx_mtx); - curchan = ic->ic_curchan; extchan = NULL;