* [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
@ 2026-04-23 7:10 Dan Carpenter
2026-04-23 14:51 ` Mark Pearson
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Dan Carpenter @ 2026-04-23 7:10 UTC (permalink / raw)
To: Even Xu
Cc: Xinpeng Sun, Jiri Kosina, Benjamin Tissoires, Mark Pearson,
Srinivas Pandruvada, linux-input, linux-kernel, kernel-janitors
If we have a partial read that is supposed to be treated as failure but
in this code we forgot to set the error code. Return -EINVAL.
Fixes: 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation")
Signed-off-by: Dan Carpenter <error27@gmail.com>
---
drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
index 16f780bc879b..cb19057f1191 100644
--- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
+++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
@@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct quickspi_device *qsdev)
dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed, ret = %d\n", ret);
dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len = %u, actual read = %u\n",
input_len, read_len);
- return ret;
+ return ret ?: -EINVAL;
}
input_rep_type = ((struct input_report_body_header *)read_buf)->input_report_type;
@@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device *qsdev)
dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed, ret = %d\n", ret);
dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u, actual = %u\n",
read_len, actual_read_len);
- return ret;
+ return ret ?: -EINVAL;
}
input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
--
2.53.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
2026-04-23 7:10 [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes Dan Carpenter
@ 2026-04-23 14:51 ` Mark Pearson
2026-04-23 15:12 ` Dan Carpenter
2026-04-24 0:53 ` Xu, Even
2026-04-28 16:35 ` Jiri Kosina
2 siblings, 1 reply; 6+ messages in thread
From: Mark Pearson @ 2026-04-23 14:51 UTC (permalink / raw)
To: Dan Carpenter, Even Xu
Cc: Xinpeng Sun, Jiri Kosina, Benjamin Tissoires, Srinivas Pandruvada,
linux-input, linux-kernel, kernel-janitors
Hi Dan,
On Thu, Apr 23, 2026, at 3:10 AM, Dan Carpenter wrote:
> If we have a partial read that is supposed to be treated as failure but
> in this code we forgot to set the error code. Return -EINVAL.
>
> Fixes: 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI
> protocol implementation")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git
> a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> index 16f780bc879b..cb19057f1191 100644
> --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> @@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct
> quickspi_device *qsdev)
> dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed, ret =
> %d\n", ret);
> dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len = %u,
> actual read = %u\n",
> input_len, read_len);
> - return ret;
> + return ret ?: -EINVAL;
> }
>
> input_rep_type = ((struct input_report_body_header
> *)read_buf)->input_report_type;
> @@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device *qsdev)
> dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed, ret =
> %d\n", ret);
> dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u,
> actual = %u\n",
> read_len, actual_read_len);
> - return ret;
> + return ret ?: -EINVAL;
> }
>
> input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
> --
> 2.53.0
I think this would be throwing away other possible different return values from thc_tic_pio_read?
You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.
Should that block be split into two separate error conditions?
Mark
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
2026-04-23 14:51 ` Mark Pearson
@ 2026-04-23 15:12 ` Dan Carpenter
2026-04-23 15:32 ` Mark Pearson
0 siblings, 1 reply; 6+ messages in thread
From: Dan Carpenter @ 2026-04-23 15:12 UTC (permalink / raw)
To: Mark Pearson
Cc: Even Xu, Xinpeng Sun, Jiri Kosina, Benjamin Tissoires,
Srinivas Pandruvada, linux-input, linux-kernel, kernel-janitors
On Thu, Apr 23, 2026 at 10:51:10AM -0400, Mark Pearson wrote:
> Hi Dan,
>
> On Thu, Apr 23, 2026, at 3:10 AM, Dan Carpenter wrote:
> > dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u,
> > actual = %u\n",
> > read_len, actual_read_len);
> > - return ret;
> > + return ret ?: -EINVAL;
> > }
> >
> > input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
> > --
> > 2.53.0
>
> I think this would be throwing away other possible different return values from thc_tic_pio_read?
> You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.
>
> Should that block be split into two separate error conditions?
It doesn't throw away any error codes. Writing "return ret ?: -EINVAL;"
is a short hand for "return ret ? ret : -EINVAL;".
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
2026-04-23 15:12 ` Dan Carpenter
@ 2026-04-23 15:32 ` Mark Pearson
0 siblings, 0 replies; 6+ messages in thread
From: Mark Pearson @ 2026-04-23 15:32 UTC (permalink / raw)
To: Dan Carpenter
Cc: Even Xu, Xinpeng Sun, Jiri Kosina, Benjamin Tissoires,
Srinivas Pandruvada, linux-input, linux-kernel, kernel-janitors
On Thu, Apr 23, 2026, at 11:12 AM, Dan Carpenter wrote:
> On Thu, Apr 23, 2026 at 10:51:10AM -0400, Mark Pearson wrote:
>> Hi Dan,
>>
>> On Thu, Apr 23, 2026, at 3:10 AM, Dan Carpenter wrote:
>> > dev_err_once(qsdev->dev, "RESET_RESPONSE body expected len = %u,
>> > actual = %u\n",
>> > read_len, actual_read_len);
>> > - return ret;
>> > + return ret ?: -EINVAL;
>> > }
>> >
>> > input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE, reset_response);
>> > --
>> > 2.53.0
>>
>> I think this would be throwing away other possible different return values from thc_tic_pio_read?
>> You'd be losing the -EINTR,-EBUSY, -ETIMEDOUT conditions that might be useful to the upper layers.
>>
>> Should that block be split into two separate error conditions?
>
> It doesn't throw away any error codes. Writing "return ret ?: -EINVAL;"
> is a short hand for "return ret ? ret : -EINVAL;".
>
Yeah, you're right - read it to fast. Sorry!
Reviewed-by: Mark Pearson <mpearson-lenovo@squebb.ca>
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
2026-04-23 7:10 [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes Dan Carpenter
2026-04-23 14:51 ` Mark Pearson
@ 2026-04-24 0:53 ` Xu, Even
2026-04-28 16:35 ` Jiri Kosina
2 siblings, 0 replies; 6+ messages in thread
From: Xu, Even @ 2026-04-24 0:53 UTC (permalink / raw)
To: Dan Carpenter
Cc: Sun, Xinpeng, Jiri Kosina, Benjamin Tissoires, Mark Pearson,
Srinivas Pandruvada, linux-input@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
> -----Original Message-----
> From: Dan Carpenter <error27@gmail.com>
> Sent: Thursday, April 23, 2026 3:10 PM
> To: Xu, Even <even.xu@intel.com>
> Cc: Sun, Xinpeng <xinpeng.sun@intel.com>; Jiri Kosina <jikos@kernel.org>;
> Benjamin Tissoires <bentiss@kernel.org>; Mark Pearson <mpearson-
> lenovo@squebb.ca>; Srinivas Pandruvada
> <srinivas.pandruvada@linux.intel.com>; linux-input@vger.kernel.org; linux-
> kernel@vger.kernel.org; kernel-janitors@vger.kernel.org
> Subject: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
>
> If we have a partial read that is supposed to be treated as failure but in this code
> we forgot to set the error code. Return -EINVAL.
>
> Fixes: 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol
> implementation")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
> ---
> drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> index 16f780bc879b..cb19057f1191 100644
> --- a/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> +++ b/drivers/hid/intel-thc-hid/intel-quickspi/quickspi-protocol.c
> @@ -94,7 +94,7 @@ static int quickspi_get_device_descriptor(struct
> quickspi_device *qsdev)
> dev_err_once(qsdev->dev, "Read DEVICE_DESCRIPTOR failed,
> ret = %d\n", ret);
> dev_err_once(qsdev->dev, "DEVICE_DESCRIPTOR expected len
> = %u, actual read = %u\n",
> input_len, read_len);
> - return ret;
> + return ret ?: -EINVAL;
> }
Good capture! If ret > 0, but read length != expected length, the error also needs to be thrown.
Thanks for the patch!
Reviewed-by: Even Xu <even.xu@intel.com>
>
> input_rep_type = ((struct input_report_body_header *)read_buf)-
> >input_report_type; @@ -318,7 +318,7 @@ int reset_tic(struct quickspi_device
> *qsdev)
> dev_err_once(qsdev->dev, "Read RESET_RESPONSE body failed,
> ret = %d\n", ret);
> dev_err_once(qsdev->dev, "RESET_RESPONSE body expected
> len = %u, actual = %u\n",
> read_len, actual_read_len);
> - return ret;
> + return ret ?: -EINVAL;
> }
>
> input_rep_type = FIELD_GET(HIDSPI_IN_REP_BDY_HDR_REP_TYPE,
> reset_response);
> --
> 2.53.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes
2026-04-23 7:10 [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes Dan Carpenter
2026-04-23 14:51 ` Mark Pearson
2026-04-24 0:53 ` Xu, Even
@ 2026-04-28 16:35 ` Jiri Kosina
2 siblings, 0 replies; 6+ messages in thread
From: Jiri Kosina @ 2026-04-28 16:35 UTC (permalink / raw)
To: Dan Carpenter
Cc: Even Xu, Xinpeng Sun, Benjamin Tissoires, Mark Pearson,
Srinivas Pandruvada, linux-input, linux-kernel, kernel-janitors
On Thu, 23 Apr 2026, Dan Carpenter wrote:
> If we have a partial read that is supposed to be treated as failure but
> in this code we forgot to set the error code. Return -EINVAL.
>
> Fixes: 9d8d51735a3a ("HID: intel-thc-hid: intel-quickspi: Add HIDSPI protocol implementation")
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Applied to hid.git#for-7.1/upstream-fixes, thanks Dan.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-04-28 16:35 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-23 7:10 [PATCH] HID: intel-thc-hid: Intel-quickspi: Fix some error codes Dan Carpenter
2026-04-23 14:51 ` Mark Pearson
2026-04-23 15:12 ` Dan Carpenter
2026-04-23 15:32 ` Mark Pearson
2026-04-24 0:53 ` Xu, Even
2026-04-28 16:35 ` Jiri Kosina
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox