netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: HighW4y2H3ll <huzh@nyu.edu>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] Fix Fortify String build warnings caused by the memcpy check in hinic_devlink.c.
Date: Thu, 16 Jun 2022 20:12:16 -0700	[thread overview]
Message-ID: <20220616201216.2eefad10@hermes.local> (raw)
In-Reply-To: <20220616235727.36546-1-huzh@nyu.edu>

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

  reply	other threads:[~2022-06-17  3:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-16 23:57 [PATCH] Fix Fortify String build warnings caused by the memcpy check in hinic_devlink.c HighW4y2H3ll
2022-06-17  3:12 ` Stephen Hemminger [this message]
2022-06-17  3:24   ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220616201216.2eefad10@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=huzh@nyu.edu \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).