mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Miri Korenblit <miriam.rachel.korenblit@intel.com>,
	Johannes Berg <johannes.berg@intel.com>,
	Sasha Levin <sashal@kernel.org>,
	kvalo@kernel.org, gregory.greenman@intel.com,
	pagadala.yesu.anjaneyulu@intel.com, dan.carpenter@linaro.org,
	somashekhar.puttagangaiah@intel.com,
	linux-wireless@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 10/17] wifi: iwlwifi: avoid memory leak
Date: Sun, 26 Jan 2025 10:03:46 -0500	[thread overview]
Message-ID: <20250126150353.957794-10-sashal@kernel.org> (raw)
In-Reply-To: <20250126150353.957794-1-sashal@kernel.org>

From: Miri Korenblit <miriam.rachel.korenblit@intel.com>

[ Upstream commit 80e96206a3ef348fbd658d98f2f43149c36df8bc ]

A caller of iwl_acpi_get_dsm_object must free the returned object.
iwl_acpi_get_dsm_integer returns immediately without freeing
it if the expected size is more than 8 bytes. Fix that.

Note that with the current code this will never happen, since the caller
of iwl_acpi_get_dsm_integer already checks that the expected size if
either 1 or 4 bytes, so it can't exceed 8 bytes.

While at it, print the DSM value instead of the return value, as this
was the intention in the first place.

Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Link: https://patch.msgid.link/20241228223206.bf61eaab99f8.Ibdc5df02f885208c222456d42c889c43b7e3b2f7@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/wireless/intel/iwlwifi/fw/acpi.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
index c96dfd7fd3dc8..84980f6a0d603 100644
--- a/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
+++ b/drivers/net/wireless/intel/iwlwifi/fw/acpi.c
@@ -123,7 +123,7 @@ static int iwl_acpi_get_dsm_integer(struct device *dev, int rev, int func,
 				    size_t expected_size)
 {
 	union acpi_object *obj;
-	int ret = 0;
+	int ret;
 
 	obj = iwl_acpi_get_dsm_object(dev, rev, func, NULL, guid);
 	if (IS_ERR(obj)) {
@@ -138,8 +138,10 @@ static int iwl_acpi_get_dsm_integer(struct device *dev, int rev, int func,
 	} else if (obj->type == ACPI_TYPE_BUFFER) {
 		__le64 le_value = 0;
 
-		if (WARN_ON_ONCE(expected_size > sizeof(le_value)))
-			return -EINVAL;
+		if (WARN_ON_ONCE(expected_size > sizeof(le_value))) {
+			ret = -EINVAL;
+			goto out;
+		}
 
 		/* if the buffer size doesn't match the expected size */
 		if (obj->buffer.length != expected_size)
@@ -160,8 +162,9 @@ static int iwl_acpi_get_dsm_integer(struct device *dev, int rev, int func,
 	}
 
 	IWL_DEBUG_DEV_RADIO(dev,
-			    "ACPI: DSM method evaluated: func=%d, ret=%d\n",
-			    func, ret);
+			    "ACPI: DSM method evaluated: func=%d, value=%lld\n",
+			    func, *value);
+	ret = 0;
 out:
 	ACPI_FREE(obj);
 	return ret;
-- 
2.39.5


  parent reply	other threads:[~2025-01-26 15:04 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-26 15:03 [PATCH AUTOSEL 6.1 01/17] tun: fix group permission check Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 02/17] mmc: core: Respect quirk_max_rate for non-UHS SDIO card Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 03/17] Revert "HID: multitouch: Add support for lenovo Y9000P Touchpad" Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 04/17] wifi: brcmsmac: add gain range check to wlc_phy_iqcal_gainparams_nphy() Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 05/17] tomoyo: don't emit warning in tomoyo_write_control() Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 06/17] mfd: lpc_ich: Add another Gemini Lake ISA bridge PCI device-id Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 07/17] HID: Wacom: Add PCI Wacom device support Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 08/17] net/mlx5: use do_aux_work for PHC overflow checks Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 09/17] wifi: brcmfmac: Check the return value of of_property_read_string_index() Sasha Levin
2025-01-26 15:03 ` Sasha Levin [this message]
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 11/17] i2c: Force ELAN06FA touchpad I2C bus freq to 100KHz Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 12/17] APEI: GHES: Have GHES honor the panic= setting Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 13/17] Bluetooth: MGMT: Fix slab-use-after-free Read in mgmt_remove_adv_monitor_sync Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 14/17] net: wwan: iosm: Fix hibernation by re-binding the driver around it Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 15/17] mmc: sdhci-msm: Correctly set the load for the regulator Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 16/17] tipc: re-order conditions in tipc_crypto_key_rcv() Sasha Levin
2025-01-26 15:03 ` [PATCH AUTOSEL 6.1 17/17] selftests/net/ipsec: Fix Null pointer dereference in rtattr_pack() Sasha Levin

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=20250126150353.957794-10-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dan.carpenter@linaro.org \
    --cc=gregory.greenman@intel.com \
    --cc=johannes.berg@intel.com \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=miriam.rachel.korenblit@intel.com \
    --cc=pagadala.yesu.anjaneyulu@intel.com \
    --cc=somashekhar.puttagangaiah@intel.com \
    --cc=stable@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®