Skip to content

Commit

Permalink
mac80211: check for allocation failure in debugfs code
Browse files Browse the repository at this point in the history
kmalloc() can fail.  Also let's move the allocation out of the
declaration block so it's easier to read.

Fixes: 4a5ecca ("mac80211: Show pending txqlen in debugfs.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
  • Loading branch information
Dan Carpenter authored and Johannes Berg committed Feb 8, 2017
1 parent 2671782 commit b2347a3
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions net/mac80211/debugfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,19 @@ static ssize_t misc_read(struct file *file, char __user *user_buf,
struct ieee80211_local *local = file->private_data;
/* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
char *buf = kzalloc(bufsz, GFP_KERNEL);
char *pos = buf, *end = buf + bufsz - 1;
char *buf;
char *pos, *end;
ssize_t rv;
int i;
int ln;

buf = kzalloc(bufsz, GFP_KERNEL);
if (!buf)
return -ENOMEM;

pos = buf;
end = buf + bufsz - 1;

pos += scnprintf(pos, end - pos, "pending:\n");

for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
Expand Down

0 comments on commit b2347a3

Please sign in to comment.