Commit b2347a32 authored by Dan Carpenter's avatar Dan Carpenter Committed by Johannes Berg

mac80211: check for allocation failure in debugfs code

kmalloc() can fail.  Also let's move the allocation out of the
declaration block so it's easier to read.

Fixes: 4a5eccaa ("mac80211: Show pending txqlen in debugfs.")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 26717828
...@@ -249,12 +249,19 @@ static ssize_t misc_read(struct file *file, char __user *user_buf, ...@@ -249,12 +249,19 @@ static ssize_t misc_read(struct file *file, char __user *user_buf,
struct ieee80211_local *local = file->private_data; struct ieee80211_local *local = file->private_data;
/* Max len of each line is 16 characters, plus 9 for 'pending:\n' */ /* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9; size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
char *buf = kzalloc(bufsz, GFP_KERNEL); char *buf;
char *pos = buf, *end = buf + bufsz - 1; char *pos, *end;
ssize_t rv; ssize_t rv;
int i; int i;
int ln; int ln;
buf = kzalloc(bufsz, GFP_KERNEL);
if (!buf)
return -ENOMEM;
pos = buf;
end = buf + bufsz - 1;
pos += scnprintf(pos, end - pos, "pending:\n"); pos += scnprintf(pos, end - pos, "pending:\n");
for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
......
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