Commit b2347a322d1f6f93f1a39fe17ed08628fc959351

Authored by Dan Carpenter
Committed by Johannes Berg
1 parent 26717828b7

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: 4a5eccaa9350 ("mac80211: Show pending txqlen in debugfs.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Showing 1 changed file with 9 additions and 2 deletions Side-by-side Diff

net/mac80211/debugfs.c
... ... @@ -249,11 +249,18 @@
249 249 struct ieee80211_local *local = file->private_data;
250 250 /* Max len of each line is 16 characters, plus 9 for 'pending:\n' */
251 251 size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9;
252   - char *buf = kzalloc(bufsz, GFP_KERNEL);
253   - char *pos = buf, *end = buf + bufsz - 1;
  252 + char *buf;
  253 + char *pos, *end;
254 254 ssize_t rv;
255 255 int i;
256 256 int ln;
  257 +
  258 + buf = kzalloc(bufsz, GFP_KERNEL);
  259 + if (!buf)
  260 + return -ENOMEM;
  261 +
  262 + pos = buf;
  263 + end = buf + bufsz - 1;
257 264  
258 265 pos += scnprintf(pos, end - pos, "pending:\n");
259 266