Skip to content

Commit 38608d3

Browse files
lituo1996gregkh
authored andcommitted
ath: dfs_pattern_detector: Fix possible null-pointer dereference in channel_detector_create()
[ Upstream commit 4b6012a ] 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>
1 parent 3c2434d commit 38608d3

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

drivers/net/wireless/ath/dfs_pattern_detector.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ static void channel_detector_exit(struct dfs_pattern_detector *dpd,
182182
if (cd == NULL)
183183
return;
184184
list_del(&cd->head);
185-
for (i = 0; i < dpd->num_radar_types; i++) {
186-
struct pri_detector *de = cd->detectors[i];
187-
if (de != NULL)
188-
de->exit(de);
185+
if (cd->detectors) {
186+
for (i = 0; i < dpd->num_radar_types; i++) {
187+
struct pri_detector *de = cd->detectors[i];
188+
if (de != NULL)
189+
de->exit(de);
190+
}
189191
}
190192
kfree(cd->detectors);
191193
kfree(cd);

0 commit comments

Comments
 (0)