* [bug report] HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces
@ 2025-01-13 6:15 Dan Carpenter
2025-01-13 6:57 ` Xu, Even
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-01-13 6:15 UTC (permalink / raw)
To: Even Xu; +Cc: linux-input
Hello Even Xu,
Commit 5282e45ccbfa ("HID: intel-thc-hid: intel-quicki2c: Add THC
QuickI2C ACPI interfaces") from Jan 6, 2025 (linux-next), leads to
the following Smatch static checker warning:
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c:59 quicki2c_acpi_get_dsm_property()
warn: potential memory corrupting cast 4 vs 2 bytes
drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
116 static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
117 {
118 struct acpi_device *adev = ACPI_COMPANION(qcdev->dev);
119 struct quicki2c_subip_acpi_parameter i2c_param;
120 struct quicki2c_subip_acpi_config i2c_config;
121 int ret = -EINVAL;
122
123 if (!adev) {
124 dev_err(qcdev->dev, "Invalid acpi device pointer\n");
125 return ret;
126 }
127
128 qcdev->acpi_dev = adev;
129
130 ret = quicki2c_acpi_get_dsm_property(adev, &i2c_hid_guid,
131 QUICKI2C_ACPI_REVISION_NUM,
132 QUICKI2C_ACPI_FUNC_NUM_HID_DESC_ADDR,
133 ACPI_TYPE_INTEGER,
^^^^^^^^^^^^^^^^^
This says INTEGER
134 &qcdev->hid_desc_addr);
^^^^^^^^^^^^^^^^^^^^^
But this is a u16 so it corrupts memory.
135 if (ret)
136 return ret;
137
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread* RE: [bug report] HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces
2025-01-13 6:15 [bug report] HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces Dan Carpenter
@ 2025-01-13 6:57 ` Xu, Even
0 siblings, 0 replies; 2+ messages in thread
From: Xu, Even @ 2025-01-13 6:57 UTC (permalink / raw)
To: Dan Carpenter; +Cc: linux-input@vger.kernel.org
Thanks Dan!
Will create a patch for the fix soon.
Best Regards,
Even Xu
> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Monday, January 13, 2025 2:16 PM
> To: Xu, Even <even.xu@intel.com>
> Cc: linux-input@vger.kernel.org
> Subject: [bug report] HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI
> interfaces
>
> Hello Even Xu,
>
> Commit 5282e45ccbfa ("HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI
> interfaces") from Jan 6, 2025 (linux-next), leads to the following Smatch static
> checker warning:
>
> drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c:59
> quicki2c_acpi_get_dsm_property()
> warn: potential memory corrupting cast 4 vs 2 bytes
>
> drivers/hid/intel-thc-hid/intel-quicki2c/pci-quicki2c.c
> 116 static int quicki2c_get_acpi_resources(struct quicki2c_device *qcdev)
> 117 {
> 118 struct acpi_device *adev = ACPI_COMPANION(qcdev->dev);
> 119 struct quicki2c_subip_acpi_parameter i2c_param;
> 120 struct quicki2c_subip_acpi_config i2c_config;
> 121 int ret = -EINVAL;
> 122
> 123 if (!adev) {
> 124 dev_err(qcdev->dev, "Invalid acpi device pointer\n");
> 125 return ret;
> 126 }
> 127
> 128 qcdev->acpi_dev = adev;
> 129
> 130 ret = quicki2c_acpi_get_dsm_property(adev, &i2c_hid_guid,
> 131 QUICKI2C_ACPI_REVISION_NUM,
> 132 QUICKI2C_ACPI_FUNC_NUM_HID_DESC_ADDR,
> 133 ACPI_TYPE_INTEGER,
> ^^^^^^^^^^^^^^^^^ This says INTEGER
>
> 134 &qcdev->hid_desc_addr);
> ^^^^^^^^^^^^^^^^^^^^^ But this is a u16 so it
> corrupts memory.
>
> 135 if (ret)
> 136 return ret;
> 137
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-13 6:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-13 6:15 [bug report] HID: intel-thc-hid: intel-quicki2c: Add THC QuickI2C ACPI interfaces Dan Carpenter
2025-01-13 6:57 ` Xu, Even
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox