linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iwlwifi: fix freeing uninitialized pointer
@ 2013-04-16 13:38 Stanislaw Gruszka
  2013-04-16 13:40 ` [PATCH 2/2] iwlwifi: remove redundant argument from iwl_dump_nic_event_log Stanislaw Gruszka
  2013-04-16 18:40 ` [PATCH 1/2] iwlwifi: fix freeing uninitialized pointer Jonas Gorski
  0 siblings, 2 replies; 7+ messages in thread
From: Stanislaw Gruszka @ 2013-04-16 13:38 UTC (permalink / raw)
  To: Johannes Berg; +Cc: ilw, linux-wireless

If on iwl_dump_nic_event_log() error occurs before that function
initialize buf, we process uninitiated pointer in
iwl_dbgfs_log_event_read() and can hit "BUG at mm/slub.c:3409"

Resolves:
https://bugzilla.redhat.com/show_bug.cgi?id=951241

Reported-by: ian.odette@eprize.com
Cc: stable@vger.kernel.org
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
---
Patch is only compile tested, but I'm sure it fixes the problem.

 drivers/net/wireless/iwlwifi/dvm/debugfs.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
index 7b8178b..cb6dd58 100644
--- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
+++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
@@ -2237,15 +2237,15 @@ static ssize_t iwl_dbgfs_log_event_read(struct file *file,
 					 size_t count, loff_t *ppos)
 {
 	struct iwl_priv *priv = file->private_data;
-	char *buf;
-	int pos = 0;
-	ssize_t ret = -ENOMEM;
+	char *buf = NULL;
+	ssize_t ret;
 
-	ret = pos = iwl_dump_nic_event_log(priv, true, &buf, true);
-	if (buf) {
-		ret = simple_read_from_buffer(user_buf, count, ppos, buf, pos);
-		kfree(buf);
-	}
+	ret = iwl_dump_nic_event_log(priv, true, &buf, true);
+	if (ret < 0)
+		goto err;
+	ret = simple_read_from_buffer(user_buf, count, ppos, buf, ret);
+err:
+	kfree(buf);
 	return ret;
 }
 
-- 
1.7.11.7


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

end of thread, other threads:[~2013-04-17  7:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-16 13:38 [PATCH 1/2] iwlwifi: fix freeing uninitialized pointer Stanislaw Gruszka
2013-04-16 13:40 ` [PATCH 2/2] iwlwifi: remove redundant argument from iwl_dump_nic_event_log Stanislaw Gruszka
2013-04-17  6:23   ` [PATCH 3/2] iwlwifi: remove unneeded goto from iwl_dbgfs_log_event_read Stanislaw Gruszka
2013-04-17  7:10     ` Julian Calaby
2013-04-17  7:12       ` Johannes Berg
2013-04-16 18:40 ` [PATCH 1/2] iwlwifi: fix freeing uninitialized pointer Jonas Gorski
2013-04-17  6:17   ` Stanislaw Gruszka

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).