diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2017-02-07 08:20:53 -0500 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2017-02-08 04:05:07 -0500 |
commit | b2347a322d1f6f93f1a39fe17ed08628fc959351 (patch) | |
tree | 6276bbd2af92b53346aa7e50871fe8069ad591e9 /net/mac80211/debugfs.c | |
parent | 26717828b75dd5c46e97f7f4a9b937d038bb2852 (diff) |
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>
Diffstat (limited to 'net/mac80211/debugfs.c')
-rw-r--r-- | net/mac80211/debugfs.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c index 47bea0babe78..5fae001f286c 100644 --- a/net/mac80211/debugfs.c +++ b/net/mac80211/debugfs.c | |||
@@ -249,12 +249,19 @@ static ssize_t misc_read(struct file *file, char __user *user_buf, | |||
249 | struct ieee80211_local *local = file->private_data; | 249 | struct ieee80211_local *local = file->private_data; |
250 | /* Max len of each line is 16 characters, plus 9 for 'pending:\n' */ | 250 | /* Max len of each line is 16 characters, plus 9 for 'pending:\n' */ |
251 | size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9; | 251 | size_t bufsz = IEEE80211_MAX_QUEUES * 16 + 9; |
252 | char *buf = kzalloc(bufsz, GFP_KERNEL); | 252 | char *buf; |
253 | char *pos = buf, *end = buf + bufsz - 1; | 253 | char *pos, *end; |
254 | ssize_t rv; | 254 | ssize_t rv; |
255 | int i; | 255 | int i; |
256 | int ln; | 256 | int ln; |
257 | 257 | ||
258 | buf = kzalloc(bufsz, GFP_KERNEL); | ||
259 | if (!buf) | ||
260 | return -ENOMEM; | ||
261 | |||
262 | pos = buf; | ||
263 | end = buf + bufsz - 1; | ||
264 | |||
258 | pos += scnprintf(pos, end - pos, "pending:\n"); | 265 | pos += scnprintf(pos, end - pos, "pending:\n"); |
259 | 266 | ||
260 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { | 267 | for (i = 0; i < IEEE80211_MAX_QUEUES; i++) { |