[BUG] net: wireless: ath9k: Possible sleep-in-atomic-context bugs

From: Jia-Ju Bai
Date: Sat Sep 15 2018 - 04:30:13 EST


My static analysis tool DSAC reports some bugs caused by mutex_lock() in ath9k_regwrite_buffer() and ath9k_reg_rmw_buffer().

Here are the related function call paths (from bottom to top) in Linux-4.17:

[FUNC] mutex_lock_nested
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 329:
mutex_lock_nested in ath9k_regwrite_buffer
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 353:
ath9k_regwrite_buffer in ath9k_regwrite
drivers/net/wireless/ath/ath9k/mac.c, 146:
[FUNC_PTR]ath9k_regwrite in ath9k_hw_abort_tx_dma
drivers/net/wireless/ath/ath9k/xmit.c, 1911:
ath9k_hw_abort_tx_dma in ath_drain_all_txq
drivers/net/wireless/ath/ath9k/main.c, 225:
ath_drain_all_txq in ath_prepare_reset
drivers/net/wireless/ath/ath9k/main.c, 307:
ath_prepare_reset in ath_reset_internal
drivers/net/wireless/ath/ath9k/main.c, 295:
spin_lock_bh in ath_reset_internal

[FUNC] mutex_lock_nested
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 392:
mutex_lock_nested in ath9k_reg_rmw_buffer
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 509:
ath9k_reg_rmw_buffer in ath9k_reg_rmw
drivers/net/wireless/ath/ath9k/mac.c, 148:
[FUNC_PTR]ath9k_reg_rmw in ath9k_hw_abort_tx_dma
drivers/net/wireless/ath/ath9k/xmit.c, 1911:
ath9k_hw_abort_tx_dma in ath_drain_all_txq
drivers/net/wireless/ath/ath9k/main.c, 225:
ath_drain_all_txq in ath_prepare_reset
drivers/net/wireless/ath/ath9k/main.c, 307:
ath_prepare_reset in ath_reset_internal
drivers/net/wireless/ath/ath9k/main.c, 295:
spin_lock_bh in ath_reset_internal

[FUNC] mutex_lock_nested
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 392:
mutex_lock_nested in ath9k_reg_rmw_buffer
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 509:
ath9k_reg_rmw_buffer in ath9k_reg_rmw
drivers/net/wireless/ath/ath9k/hw.c, 2188:
[FUNC_PTR]ath9k_reg_rmw in ath9k_hw_set_power_awake
drivers/net/wireless/ath/ath9k/hw.c, 2237:
ath9k_hw_set_power_awake in ath9k_hw_setpower
drivers/net/wireless/ath/ath9k/main.c, 125:
ath9k_hw_setpower in ath9k_ps_wakeup
drivers/net/wireless/ath/ath9k/main.c, 386:
ath9k_ps_wakeup in ath9k_tasklet (tasklet handler)

[FUNC] mutex_lock_nested
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 329:
mutex_lock_nested in ath9k_regwrite_buffer
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 353:
ath9k_regwrite_buffer in ath9k_regwrite
drivers/net/wireless/ath/ath9k/htc_drv_init.c, 503:
[FUNC_PTR]ath9k_regwrite in ath9k_reg_rmw
drivers/net/wireless/ath/ath9k/hw.c, 2188:
[FUNC_PTR]ath9k_reg_rmw in ath9k_hw_set_power_awake
drivers/net/wireless/ath/ath9k/hw.c, 2237:
ath9k_hw_set_power_awake in ath9k_hw_setpower
drivers/net/wireless/ath/ath9k/main.c, 125:
ath9k_hw_setpower in ath9k_ps_wakeup
drivers/net/wireless/ath/ath9k/main.c, 386:
ath9k_ps_wakeup in ath9k_tasklet (tasklet handler)

Note that [FUNC_PTR] means a function pointer call is used.

I am not sure how to well fix these bugs if they are real.


Best wishes,
Jia-Ju Bai