Skip to content

Commit 394ee48

Browse files
zhou1615gregkh
authored andcommitted
ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan()
[ Upstream commit eccd251 ] 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: d5c6515 ("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 Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f6e4a6c commit 394ee48

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

  • drivers/net/wireless/ath/ath11k

‎drivers/net/wireless/ath/ath11k/mac.c‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2320,9 +2320,12 @@ static int ath11k_mac_op_hw_scan(struct ieee80211_hw *hw,
23202320
arg.scan_id = ATH11K_SCAN_ID;
23212321

23222322
if (req->ie_len) {
2323+
arg.extraie.ptr = kmemdup(req->ie, req->ie_len, GFP_KERNEL);
2324+
if (!arg.extraie.ptr) {
2325+
ret = -ENOMEM;
2326+
goto exit;
2327+
}
23232328
arg.extraie.len = req->ie_len;
2324-
arg.extraie.ptr = kzalloc(req->ie_len, GFP_KERNEL);
2325-
memcpy(arg.extraie.ptr, req->ie, req->ie_len);
23262329
}
23272330

23282331
if (req->n_ssids) {

0 commit comments

Comments
 (0)