ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_...
authorTuo Li <islituo@gmail.com>
Thu, 5 Aug 2021 15:38:53 +0000 (08:38 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Nov 2021 18:16:15 +0000 (19:16 +0100)
commitdd267d35d82a523c9f7f953fe7efad42fedc82f7
tree3e6741fe7df0a21f182677f92fe1a3f60b0ef552
parent4e4f6e33d6f22b073697098ef6fa0f33e44c391c
ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create()

[ Upstream commit 4b6012a7830b813799a7faf40daa02a837e0fd5b ]

kzalloc() is used to allocate memory for cd->detectors, and if it fails,
channel_detector_exit() behind the label fail will be called:
  channel_detector_exit(dpd, cd);

In channel_detector_exit(), cd->detectors is dereferenced through:
  struct pri_detector *de = cd->detectors[i];

To fix this possible null-pointer dereference, check cd->detectors before
the for loop to dereference cd->detectors.

Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/20210805153854.154066-1-islituo@gmail.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/ath/dfs_pattern_detector.c