All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luca Coelho <luca@coelho.fi>
To: kvalo@codeaurora.org
Cc: luca@coelho.fi, linux-wireless@vger.kernel.org
Subject: [PATCH for v5.15 4/5] iwlwifi: pnvm: read EFI data only if long enough
Date: Sat, 16 Oct 2021 11:43:58 +0300	[thread overview]
Message-ID: <iwlwifi.20211016114029.33feba783518.I54a5cf33975d0330792b3d208b225d479e168f32@changeid> (raw)
In-Reply-To: <20211016084359.246930-1-luca@coelho.fi>

From: Johannes Berg <johannes.berg@intel.com>

If the data we get from EFI is not even long enough for
the package struct we expect then ignore it entirely.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Fixes: a1a6a4cf49ec ("iwlwifi: pnvm: implement reading PNVM from UEFI")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
---
 drivers/net/wireless/intel/iwlwifi/fw/pnvm.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
index 9b0eee53488a..069fcbc46d2b 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
@@ -284,9 +284,13 @@ int iwl_pnvm_load(struct iwl_trans *trans,
 	/* First attempt to get the PNVM from BIOS */
 	package = iwl_uefi_get_pnvm(trans, &len);
 	if (!IS_ERR_OR_NULL(package)) {
-		/* we need only the data */
-		len -= sizeof(*package);
-		data = kmemdup(package->data, len, GFP_KERNEL);
+		if (len >= sizeof(*package)) {
+			/* we need only the data */
+			len -= sizeof(*package);
+			data = kmemdup(package->data, len, GFP_KERNEL);
+		} else {
+			data = NULL;
+		}
 
 		/* free package regardless of whether kmemdup succeeded */
 		kfree(package);
-- 
2.33.0


  parent reply	other threads:[~2021-10-16  8:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-16  8:43 [PATCH for v5.15 0/5] iwlwifi: fixes intended for v5.15 2021-10-16 Luca Coelho
2021-10-16  8:43 ` [PATCH for v5.15 1/5] iwlwifi: mvm: reset PM state on unsuccessful resume Luca Coelho
2021-10-20  9:31   ` Kalle Valo
2021-10-16  8:43 ` [PATCH for v5.15 2/5] iwlwifi: change all JnP to NO-160 configuration Luca Coelho
2021-10-16  8:43 ` [PATCH for v5.15 3/5] iwlwifi: pnvm: don't kmemdup() more than we have Luca Coelho
2021-10-16  8:43 ` Luca Coelho [this message]
2021-10-16  8:43 ` [PATCH for v5.15 5/5] iwlwifi: cfg: set low-latency-xtal for some integrated So devices Luca Coelho
2021-10-18  7:55 ` [PATCH for v5.15 0/5] iwlwifi: fixes intended for v5.15 2021-10-16 Kalle Valo
2021-10-22  6:32   ` Luca Coelho

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=iwlwifi.20211016114029.33feba783518.I54a5cf33975d0330792b3d208b225d479e168f32@changeid \
    --to=luca@coelho.fi \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /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 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.