linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ganapathi Bhat <gbhat@marvell.com>
To: <linux-wireless@vger.kernel.org>
Cc: Cathy Luo <cluo@marvell.com>, Zhiyuan Yang <yangzy@marvell.com>,
	James Cao <jcao@marvell.com>, Rakesh Parmar <rakeshp@marvell.com>,
	Brian Norris <briannorris@chromium.org>,
	Sharvari Harisangam <sharvari@marvell.com>,
	Ganapathi Bhat <gbhat@marvell.com>
Subject: [PATCH 1/2] mwifiex: fix requesting zero memory for firmware dump
Date: Wed, 13 Nov 2019 10:45:31 +0530	[thread overview]
Message-ID: <1573622132-16181-1-git-send-email-gbhat@marvell.com> (raw)

From: Sharvari Harisangam <sharvari@marvell.com>

mwifiex_pcie_fw_dump would read firmware scratch registers, to
get the size of the dump. It does a vmalloc of memory_size + 1,
read above, to save the dump. It is possible that the value read
by  memory_size scratch register be invalid, i.e 0xffffffff. This
would pass an invalid size(0) to vmalloc. To fix this check for
invalid scratch register read.

Signed-off-by: Sharvari Harisangam <sharvari@marvell.com>
Signed-off-by: Ganapathi Bhat <gbhat@marvell.com>
---
 drivers/net/wireless/marvell/mwifiex/pcie.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c
index fc1706d..483b521 100644
--- a/drivers/net/wireless/marvell/mwifiex/pcie.c
+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c
@@ -2727,6 +2727,13 @@ static void mwifiex_pcie_fw_dump(struct mwifiex_adapter *adapter)
 			break;
 		}
 
+		if (memory_size == 0xffffffff) {
+			mwifiex_dbg(adapter, ERROR,
+				    "Invalid dump size: 0x%x, for %s\n",
+				    memory_size, entry->mem_name);
+			return;
+		}
+
 		mwifiex_dbg(adapter, DUMP,
 			    "%s_SIZE=0x%x\n", entry->mem_name, memory_size);
 		entry->mem_ptr = vmalloc(memory_size + 1);
-- 
1.9.1


             reply	other threads:[~2019-11-13  5:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-13  5:15 Ganapathi Bhat [this message]
2019-11-13  5:15 ` [PATCH 2/2] mwifiex: do not download TX packets if interface has not resumed Ganapathi Bhat
2019-11-14 15:18 ` [PATCH 1/2] mwifiex: fix requesting zero memory for firmware dump Kalle Valo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1573622132-16181-1-git-send-email-gbhat@marvell.com \
    --to=gbhat@marvell.com \
    --cc=briannorris@chromium.org \
    --cc=cluo@marvell.com \
    --cc=jcao@marvell.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=rakeshp@marvell.com \
    --cc=sharvari@marvell.com \
    --cc=yangzy@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).