diff mbox series

hid: intel-ish-hid: avoid bogus uninitialized-variable warning

Message ID 20200428215337.4094575-1-arnd@arndb.de (mailing list archive)
State Mainlined
Commit 0b66fb3e6b7a53688f8e20945ac78cd3d832c65f
Delegated to: Jiri Kosina
Headers show
Series hid: intel-ish-hid: avoid bogus uninitialized-variable warning | expand

Commit Message

Arnd Bergmann April 28, 2020, 9:53 p.m. UTC
Older compilers like gcc-4.8 don't see that the variable is
initialized when it is used:

In file included from include/linux/compiler_types.h:68:0,
                 from <command-line>:0:
drivers/hid/intel-ish-hid/ishtp-fw-loader.c: In function 'load_fw_from_host':
include/linux/compiler-gcc.h:75:45: warning: 'fw_info.ldr_capability.max_dma_buf_size' may be used uninitialized in this function [-Wmaybe-uninitialized]
 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
                                             ^
drivers/hid/intel-ish-hid/ishtp-fw-loader.c:770:22: note: 'fw_info.ldr_capability.max_dma_buf_size' was declared here
  struct shim_fw_info fw_info;
                      ^

Make sure to initialize it before returning an error from ish_query_loader_prop().

Fixes: 91b228107da3 ("HID: intel-ish-hid: ISH firmware loader client driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Srinivas Pandruvada April 29, 2020, 1:36 a.m. UTC | #1
On Tue, 2020-04-28 at 23:53 +0200, Arnd Bergmann wrote:
> Older compilers like gcc-4.8 don't see that the variable is
> initialized when it is used:
> 
> In file included from include/linux/compiler_types.h:68:0,
>                  from <command-line>:0:
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c: In function
> 'load_fw_from_host':
> include/linux/compiler-gcc.h:75:45: warning:
> 'fw_info.ldr_capability.max_dma_buf_size' may be used uninitialized
> in this function [-Wmaybe-uninitialized]
>  #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix),
> __COUNTER__)
>                                              ^
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c:770:22: note:
> 'fw_info.ldr_capability.max_dma_buf_size' was declared here
>   struct shim_fw_info fw_info;
>                       ^
> 
> Make sure to initialize it before returning an error from
> ish_query_loader_prop().
> 
> Fixes: 91b228107da3 ("HID: intel-ish-hid: ISH firmware loader client
> driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>


> ---
>  drivers/hid/intel-ish-hid/ishtp-fw-loader.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> index aa2dbed30fc3..6cf59fd26ad7 100644
> --- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> +++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
> @@ -480,6 +480,7 @@ static int ish_query_loader_prop(struct
> ishtp_cl_data *client_data,
>  			    sizeof(ldr_xfer_query_resp));
>  	if (rv < 0) {
>  		client_data->flag_retry = true;
> +		*fw_info = (struct shim_fw_info){};
>  		return rv;
>  	}
>  
> @@ -489,6 +490,7 @@ static int ish_query_loader_prop(struct
> ishtp_cl_data *client_data,
>  			"data size %d is not equal to size of
> loader_xfer_query_response %zu\n",
>  			rv, sizeof(struct loader_xfer_query_response));
>  		client_data->flag_retry = true;
> +		*fw_info = (struct shim_fw_info){};
>  		return -EMSGSIZE;
>  	}
>
Jiri Kosina May 5, 2020, 7:55 a.m. UTC | #2
On Tue, 28 Apr 2020, Arnd Bergmann wrote:

> Older compilers like gcc-4.8 don't see that the variable is
> initialized when it is used:
> 
> In file included from include/linux/compiler_types.h:68:0,
>                  from <command-line>:0:
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c: In function 'load_fw_from_host':
> include/linux/compiler-gcc.h:75:45: warning: 'fw_info.ldr_capability.max_dma_buf_size' may be used uninitialized in this function [-Wmaybe-uninitialized]
>  #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
>                                              ^
> drivers/hid/intel-ish-hid/ishtp-fw-loader.c:770:22: note: 'fw_info.ldr_capability.max_dma_buf_size' was declared here
>   struct shim_fw_info fw_info;
>                       ^
> 
> Make sure to initialize it before returning an error from ish_query_loader_prop().
> 
> Fixes: 91b228107da3 ("HID: intel-ish-hid: ISH firmware loader client driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
index aa2dbed30fc3..6cf59fd26ad7 100644
--- a/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
+++ b/drivers/hid/intel-ish-hid/ishtp-fw-loader.c
@@ -480,6 +480,7 @@  static int ish_query_loader_prop(struct ishtp_cl_data *client_data,
 			    sizeof(ldr_xfer_query_resp));
 	if (rv < 0) {
 		client_data->flag_retry = true;
+		*fw_info = (struct shim_fw_info){};
 		return rv;
 	}
 
@@ -489,6 +490,7 @@  static int ish_query_loader_prop(struct ishtp_cl_data *client_data,
 			"data size %d is not equal to size of loader_xfer_query_response %zu\n",
 			rv, sizeof(struct loader_xfer_query_response));
 		client_data->flag_retry = true;
+		*fw_info = (struct shim_fw_info){};
 		return -EMSGSIZE;
 	}