diff mbox series

[next] HID: intel-thc-hid: intel-quicki2c: fix potential memory corruption

Message ID 20250113085047.2100403-1-even.xu@intel.com (mailing list archive)
State New
Delegated to: Jiri Kosina
Headers show
Series [next] HID: intel-thc-hid: intel-quicki2c: fix potential memory corruption | expand

Commit Message

Even Xu Jan. 13, 2025, 8:50 a.m. UTC
Use U32 to get value from ACPI and explicitly cast to U16.

fixes: 5282e45ccbfa ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces")
Signed-off-by: Even Xu <even.xu@intel.com>
---
 drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Benjamin Tissoires Jan. 13, 2025, 10:08 a.m. UTC | #1
On Mon, 13 Jan 2025 16:50:47 +0800, Even Xu wrote:
> Use U32 to get value from ACPI and explicitly cast to U16.
> 
> 

Applied to hid/hid.git (for-6.14/intel-thc), thanks!

[1/1] HID: intel-thc-hid: intel-quicki2c: fix potential memory corruption
      https://git.kernel.org/hid/hid/c/d08a1049659a

Cheers,
diff mbox series

Patch

diff --git a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
index b56c72124821..2de93f4a25ca 100644
--- a/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
+++ b/drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
@@ -118,6 +118,7 @@  static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
 	struct acpi_device *adev = ACPI_COMPANION(qcdev->dev);
 	struct quicki2c_subip_acpi_parameter i2c_param;
 	struct quicki2c_subip_acpi_config i2c_config;
+	u32 hid_desc_addr;
 	int ret = -EINVAL;
 
 	if (!adev) {
@@ -131,10 +132,12 @@  static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
 					     QUICKI2C_ACPI_REVISION_NUM,
 					     QUICKI2C_ACPI_FUNC_NUM_HID_DESC_ADDR,
 					     ACPI_TYPE_INTEGER,
-					     &qcdev->hid_desc_addr);
+					     &hid_desc_addr);
 	if (ret)
 		return ret;
 
+	qcdev->hid_desc_addr = (u16)hid_desc_addr;
+
 	ret = quicki2c_acpi_get_dsm_property(adev, &thc_platform_guid,
 					     QUICKI2C_ACPI_REVISION_NUM,
 					     QUICKI2C_ACPI_FUNC_NUM_ACTIVE_LTR_VAL,