Commit 4be6718c authored by Janusz Dziedzic's avatar Janusz Dziedzic Committed by John W. Linville

ath9k: dfs_debug fix possible NULL dereference

Fix possible NULL (sc->dfs_detector) pointer dereference.

Detected by Smatch:
drivers/net/wireless/ath/ath9k/dfs_debug.c:67 read_file_dfs()
error: we previously assumed 'sc->dfs_detector' could be null (see line 47)
Signed-off-by: default avatarJanusz Dziedzic <janusz.dziedzic@tieto.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 87eb0167
...@@ -44,14 +44,20 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf, ...@@ -44,14 +44,20 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
if (buf == NULL) if (buf == NULL)
return -ENOMEM; return -ENOMEM;
if (sc->dfs_detector)
dfs_pool_stats = sc->dfs_detector->get_stats(sc->dfs_detector);
len += scnprintf(buf + len, size - len, "DFS support for " len += scnprintf(buf + len, size - len, "DFS support for "
"macVersion = 0x%x, macRev = 0x%x: %s\n", "macVersion = 0x%x, macRev = 0x%x: %s\n",
hw_ver->macVersion, hw_ver->macRev, hw_ver->macVersion, hw_ver->macRev,
(sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ? (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_DFS) ?
"enabled" : "disabled"); "enabled" : "disabled");
if (!sc->dfs_detector) {
len += scnprintf(buf + len, size - len,
"DFS detector not enabled\n");
goto exit;
}
dfs_pool_stats = sc->dfs_detector->get_stats(sc->dfs_detector);
len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n"); len += scnprintf(buf + len, size - len, "Pulse detector statistics:\n");
ATH9K_DFS_STAT("pulse events reported ", pulses_total); ATH9K_DFS_STAT("pulse events reported ", pulses_total);
ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs); ATH9K_DFS_STAT("invalid pulse events ", pulses_no_dfs);
...@@ -76,6 +82,7 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf, ...@@ -76,6 +82,7 @@ static ssize_t read_file_dfs(struct file *file, char __user *user_buf,
ATH9K_DFS_POOL_STAT("Seqs. alloc error ", pseq_alloc_error); ATH9K_DFS_POOL_STAT("Seqs. alloc error ", pseq_alloc_error);
ATH9K_DFS_POOL_STAT("Seqs. in use ", pseq_used); ATH9K_DFS_POOL_STAT("Seqs. in use ", pseq_used);
exit:
if (len > size) if (len > size)
len = size; len = size;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment