diff mbox series

Fix Fortify String build warnings caused by the memcpy check in hinic_devlink.c.

Message ID 20220616235727.36546-1-huzh@nyu.edu (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series Fix Fortify String build warnings caused by the memcpy check in hinic_devlink.c. | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 613 this patch: 35
netdev/cc_maintainers warning 8 maintainers not CCed: simon.horman@corigine.com olteanv@gmail.com jiri@nvidia.com pabeni@redhat.com kuba@kernel.org edumazet@google.com davem@davemloft.net leon@kernel.org
netdev/build_clang fail Errors and warnings before: 348 this patch: 31
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff fail author Signed-off-by missing
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 638 this patch: 35
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 22 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Zhenghao Hu June 16, 2022, 11:57 p.m. UTC
...
	memcpy(&host_image->image_section_info[i],
	       	&fw_image->fw_section_info[i],
	       	sizeof(struct fw_section_info_st));
...
---
 drivers/net/ethernet/huawei/hinic/hinic_devlink.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

Comments

Stephen Hemminger June 17, 2022, 3:12 a.m. UTC | #1
On Thu, 16 Jun 2022 19:57:27 -0400
HighW4y2H3ll <huzh@nyu.edu> wrote:

> ...
> 	memcpy(&host_image->image_section_info[i],
> 	       	&fw_image->fw_section_info[i],
> 	       	sizeof(struct fw_section_info_st));
> ...
> ---
>  drivers/net/ethernet/huawei/hinic/hinic_devlink.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.h b/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
> index 46760d607b9b..d7b26830c9ee 100644
> --- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
> +++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
> @@ -92,14 +92,20 @@ struct fw_image_st {
>  		u32 fw_section_cnt:16;
>  		u32 resd:16;
>  	} fw_info;
> -	struct fw_section_info_st fw_section_info[MAX_FW_TYPE_NUM];
> +	union {
> +	struct_group(info, fw_section_info_st fw_section_info[0];);
> +	struct fw_section_info_st __data[MAX_FW_TYPE_NUM];
> +	};
>  	u32 device_id;
>  	u32 res[101];
>  	void *bin_data;
>  };
>  
>  struct host_image_st {
> -	struct fw_section_info_st image_section_info[MAX_FW_TYPE_NUM];
> +	union {
> +	struct_group(info, fw_section_info_st image_section_info[0];);
> +	struct fw_section_info_st __data[MAX_FW_TYPE_NUM];
> +	};
>  	struct {
>  		u32 up_total_len;
>  		u32 fw_version;

Patch is missing signed-of-by

Using [0] inside union will cause warnings in future since you are referencing
outside of bounds of array.

Also indentation is wrong, you need to indent the union
Jakub Kicinski June 17, 2022, 3:24 a.m. UTC | #2
On Thu, 16 Jun 2022 20:12:16 -0700 Stephen Hemminger wrote:
> Patch is missing signed-of-by
> 
> Using [0] inside union will cause warnings in future since you are referencing
> outside of bounds of array.
> 
> Also indentation is wrong, you need to indent the union

BTW there's already a fix from Kees pending for this.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.h b/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
index 46760d607b9b..d7b26830c9ee 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
+++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.h
@@ -92,14 +92,20 @@  struct fw_image_st {
 		u32 fw_section_cnt:16;
 		u32 resd:16;
 	} fw_info;
-	struct fw_section_info_st fw_section_info[MAX_FW_TYPE_NUM];
+	union {
+	struct_group(info, fw_section_info_st fw_section_info[0];);
+	struct fw_section_info_st __data[MAX_FW_TYPE_NUM];
+	};
 	u32 device_id;
 	u32 res[101];
 	void *bin_data;
 };
 
 struct host_image_st {
-	struct fw_section_info_st image_section_info[MAX_FW_TYPE_NUM];
+	union {
+	struct_group(info, fw_section_info_st image_section_info[0];);
+	struct fw_section_info_st __data[MAX_FW_TYPE_NUM];
+	};
 	struct {
 		u32 up_total_len;
 		u32 fw_version;