All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] mac80211: check for allocation failure in debugfs code
@ 2017-02-07 13:20 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-02-07 13:20 UTC (permalink / raw)
  To: Johannes Berg, Ben Greear; +Cc: linux-wireless, kernel-janitors

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>

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index f62cd0e13c58..4689353aa263 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,
 	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++) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch] mac80211: check for allocation failure in debugfs code
@ 2017-02-07 13:20 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2017-02-07 13:20 UTC (permalink / raw)
  To: Johannes Berg, Ben Greear; +Cc: linux-wireless, kernel-janitors

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>

diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
index f62cd0e13c58..4689353aa263 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,
 	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++) {

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [patch] mac80211: check for allocation failure in debugfs code
  2017-02-07 13:20 ` Dan Carpenter
@ 2017-02-08  9:05   ` Johannes Berg
  -1 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2017-02-08  9:05 UTC (permalink / raw)
  To: Dan Carpenter, Ben Greear; +Cc: linux-wireless, kernel-janitors

On Tue, 2017-02-07 at 16:20 +0300, Dan Carpenter wrote:
> kmalloc() can fail.  Also let's move the allocation out of the
> declaration block so it's easier to read.
> 
Applied, thanks.

johannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [patch] mac80211: check for allocation failure in debugfs code
@ 2017-02-08  9:05   ` Johannes Berg
  0 siblings, 0 replies; 4+ messages in thread
From: Johannes Berg @ 2017-02-08  9:05 UTC (permalink / raw)
  To: Dan Carpenter, Ben Greear; +Cc: linux-wireless, kernel-janitors

On Tue, 2017-02-07 at 16:20 +0300, Dan Carpenter wrote:
> kmalloc() can fail.  Also let's move the allocation out of the
> declaration block so it's easier to read.
> 
Applied, thanks.

johannes

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-08  9:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 13:20 [patch] mac80211: check for allocation failure in debugfs code Dan Carpenter
2017-02-07 13:20 ` Dan Carpenter
2017-02-08  9:05 ` Johannes Berg
2017-02-08  9:05   ` Johannes Berg

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.