diff options
author | Zhou Qingyang <zhou1615@umn.edu> | 2021-12-13 10:53:07 +0100 |
---|---|---|
committer | Kalle Valo <quic_kvalo@quicinc.com> | 2021-12-14 16:30:26 +0100 |
commit | eccd25136386a04ebf46a64f3a34e8e0fab6d9e1 (patch) | |
tree | 1f8c2c8322e04f3652775e077c89609e598ddc4c /drivers/net | |
parent | ath11k: Fix deleting uninitialized kernel timer during fragment cache flush (diff) | |
download | linux-eccd25136386a04ebf46a64f3a34e8e0fab6d9e1.tar.xz linux-eccd25136386a04ebf46a64f3a34e8e0fab6d9e1.zip |
ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan()
In ath11k_mac_op_hw_scan(), the return value of kzalloc() is directly
used in memcpy(), which may lead to a NULL pointer dereference on
failure of kzalloc().
Fix this bug by adding a check of arg.extraie.ptr.
This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.
Builds with CONFIG_ATH11K=m show no new warnings, and our static
analyzer no longer warns about this code.
Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Zhou Qingyang <zhou1615@umn.edu>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20211202155348.71315-1-zhou1615@umn.edu
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/ath/ath11k/mac.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index e8b76a311a54..6361378cb407 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -3520,9 +3520,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw, arg.scan_id = ATH11K_SCAN_ID; if (req->ie_len) { + arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL); + if (!arg.extraie.ptr) { + ret = -ENOMEM; + goto exit; + } arg.extraie.len = req->ie_len; - arg.extraie.ptr = kzalloc(req->ie_len, GFP_KERNEL); - memcpy(arg.extraie.ptr, req->ie, req->ie_len); } if (req->n_ssids) { |