Linux Input/HID development
 help / color / mirror / Atom feed
* [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
@ 2024-10-04  7:59 SurajSonawane2415
  2024-10-04  8:32 ` Benjamin Tissoires
  2024-10-04  8:35 ` Benjamin Tissoires
  0 siblings, 2 replies; 4+ messages in thread
From: SurajSonawane2415 @ 2024-10-04  7:59 UTC (permalink / raw)
  To: srinivas.pandruvada, jikos, bentiss
  Cc: linux-input, linux-kernel, SurajSonawane2415

Fix the uninitialized symbol 'rv' in the function ish_fw_xfer_direct_dma
to resolve the following warning from the smatch tool:
drivers/hid/intel-ish-hid/ishtp-fw-loader.c:714 ish_fw_xfer_direct_dma()
error: uninitialized symbol 'rv'.
Initialize 'rv' to 0 to prevent undefined behavior from uninitialized
access.

Signed-off-by: SurajSonawane2415 <surajsonawane0215@gmail.com>
---
 drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
index e157863a8..b3c3cfcd9 100644
--- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
+++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
@@ -635,7 +635,7 @@ static int ish_fw_xfer_direct_dma(struct ishtp_cl_data *client_data,
 				  const struct firmware *fw,
 				  const struct shim_fw_info fw_info)
 {
-	int rv;
+	int rv = 0;
 	void *dma_buf;
 	dma_addr_t dma_buf_phy;
 	u32 fragment_offset, fragment_size, payload_max_size;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
  2024-10-04  7:59 [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma SurajSonawane2415
@ 2024-10-04  8:32 ` Benjamin Tissoires
  2024-10-04  8:35 ` Benjamin Tissoires
  1 sibling, 0 replies; 4+ messages in thread
From: Benjamin Tissoires @ 2024-10-04  8:32 UTC (permalink / raw)
  To: SurajSonawane2415; +Cc: srinivas.pandruvada, jikos, linux-input, linux-kernel

On Oct 04 2024, SurajSonawane2415 wrote:
> Fix the uninitialized symbol 'rv' in the function ish_fw_xfer_direct_dma
> to resolve the following warning from the smatch tool:
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c:714 ish_fw_xfer_direct_dma()
> error: uninitialized symbol 'rv'.
> Initialize 'rv' to 0 to prevent undefined behavior from uninitialized
> access.

Thanks for the patch!

FWIW, I tried to understand why this went unnoticced for so long: the
only case where rv might be used uninitialized is if fw->size == 0.

In that case, all that happens is that load_fw_from_host() tries to call
ish_fw_start() which will in turn overwrite the return value.

So I'm not sure if request_firmware() can return a firmware of size 0,
and if ish_fw_start() will be happy about that, but I would hope one of
the 2 would complain and not crash the kernel.

Anyway, I'll grab this one and adding Fixes and CC:stable as this might
catch an interesting bug, and fixing smatch complains is always good.

Cheers,
Benjamin


> 
> Signed-off-by: SurajSonawane2415 <surajsonawane0215@gmail.com>
> ---
>  drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> index e157863a8..b3c3cfcd9 100644
> --- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> +++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> @@ -635,7 +635,7 @@ static int ish_fw_xfer_direct_dma(struct ishtp_cl_data *client_data,
>  				  const struct firmware *fw,
>  				  const struct shim_fw_info fw_info)
>  {
> -	int rv;
> +	int rv = 0;
>  	void *dma_buf;
>  	dma_addr_t dma_buf_phy;
>  	u32 fragment_offset, fragment_size, payload_max_size;
> -- 
> 2.34.1
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
  2024-10-04  7:59 [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma SurajSonawane2415
  2024-10-04  8:32 ` Benjamin Tissoires
@ 2024-10-04  8:35 ` Benjamin Tissoires
  2024-10-04 10:20   ` [PATCH] Applied: " SurajSonawane2415
  1 sibling, 1 reply; 4+ messages in thread
From: Benjamin Tissoires @ 2024-10-04  8:35 UTC (permalink / raw)
  To: srinivas.pandruvada, jikos, SurajSonawane2415; +Cc: linux-input, linux-kernel

On Fri, 04 Oct 2024 13:29:44 +0530, SurajSonawane2415 wrote:
> Fix the uninitialized symbol 'rv' in the function ish_fw_xfer_direct_dma
> to resolve the following warning from the smatch tool:
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c:714 ish_fw_xfer_direct_dma()
> error: uninitialized symbol 'rv'.
> Initialize 'rv' to 0 to prevent undefined behavior from uninitialized
> access.
> 
> [...]

Applied to hid/hid.git (for-6.12/upstream-fixes), thanks!

[1/1] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
      https://git.kernel.org/hid/hid/c/d41bff05a61f

Cheers,
-- 
Benjamin Tissoires <bentiss@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Applied: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma
  2024-10-04  8:35 ` Benjamin Tissoires
@ 2024-10-04 10:20   ` SurajSonawane2415
  0 siblings, 0 replies; 4+ messages in thread
From: SurajSonawane2415 @ 2024-10-04 10:20 UTC (permalink / raw)
  To: bentiss
  Cc: jikos, linux-input, linux-kernel, srinivas.pandruvada,
	surajsonawane0215

Hi Benjamin,

Thanks for applying the patch and your feedback. I appreciate the support!  
Thank you for your time.

Best regards,  
Suraj Sonawane

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-04 10:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-04  7:59 [PATCH] hid: intel-ish-hid: Fix uninitialized variable 'rv' in ish_fw_xfer_direct_dma SurajSonawane2415
2024-10-04  8:32 ` Benjamin Tissoires
2024-10-04  8:35 ` Benjamin Tissoires
2024-10-04 10:20   ` [PATCH] Applied: " SurajSonawane2415

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox