All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Easi <aeasi@marvell.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	<linux-scsi@vger.kernel.org>,
	"Nilesh Javali" <njavali@marvell.com>,
	Himanshu Madhani <himanshu.madhani@oracle.com>,
	Quinn Tran <qutran@marvell.com>, Martin Wilck <mwilck@suse.com>,
	"Daniel Wagner" <dwagner@suse.de>,
	Roman Bolshakov <r.bolshakov@yadro.com>
Subject: Re: [PATCH v4 06/11] qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE
Date: Mon, 11 May 2020 00:36:00 -0700	[thread overview]
Message-ID: <alpine.LRH.2.21.9999.2005110035150.23618@irv1user01.caveonetworks.com> (raw)
In-Reply-To: <20200427030310.19687-7-bvanassche@acm.org>

On Sun, 26 Apr 2020, 8:03pm, Bart Van Assche wrote:

> This patch fixes the following Coverity complaint without changing any
> functionality:
> 
> CID 337793 (#1 of 1): Wrong size argument (SIZEOF_MISMATCH)
> suspicious_sizeof: Passing argument ha->fcp_prio_cfg of type
> struct qla_fcp_prio_cfg * and argument 32768UL to function memset is
> suspicious because a multiple of sizeof (struct qla_fcp_prio_cfg) /*48*/
> is expected.
> 
> memset(ha->fcp_prio_cfg, 0, FCP_PRIO_CFG_SIZE);
> 
> Cc: Nilesh Javali <njavali@marvell.com>
> Cc: Himanshu Madhani <himanshu.madhani@oracle.com>
> Cc: Quinn Tran <qutran@marvell.com>
> Cc: Martin Wilck <mwilck@suse.com>
> Cc: Daniel Wagner <dwagner@suse.de>
> Cc: Roman Bolshakov <r.bolshakov@yadro.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/scsi/qla2xxx/qla_fw.h | 3 ++-
>  drivers/scsi/qla2xxx/qla_os.c | 1 +
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/scsi/qla2xxx/qla_fw.h b/drivers/scsi/qla2xxx/qla_fw.h
> index b364a497e33d..4fa34374f34f 100644
> --- a/drivers/scsi/qla2xxx/qla_fw.h
> +++ b/drivers/scsi/qla2xxx/qla_fw.h
> @@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {
>  #define FCP_PRIO_ATTR_PERSIST   0x2
>  	uint8_t  reserved;      /* Reserved for future use          */
>  #define FCP_PRIO_CFG_HDR_SIZE   0x10
> -	struct qla_fcp_prio_entry entry[1];     /* fcp priority entries  */
> +	struct qla_fcp_prio_entry entry[1023]; /* fcp priority entries  */
>  #define FCP_PRIO_CFG_ENTRY_SIZE 0x20
> +	uint8_t  reserved2[16];
>  };
>  
>  #define FCP_PRIO_CFG_SIZE       (32*1024) /* fcp prio data per port*/
> diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
> index 2dd9c2a39cd5..30c2750c5745 100644
> --- a/drivers/scsi/qla2xxx/qla_os.c
> +++ b/drivers/scsi/qla2xxx/qla_os.c
> @@ -7877,6 +7877,7 @@ qla2x00_module_init(void)
>  	BUILD_BUG_ON(sizeof(struct qla82xx_uri_data_desc) != 28);
>  	BUILD_BUG_ON(sizeof(struct qla82xx_uri_table_desc) != 32);
>  	BUILD_BUG_ON(sizeof(struct qla83xx_fw_dump) != 51196);
> +	BUILD_BUG_ON(sizeof(struct qla_fcp_prio_cfg) != FCP_PRIO_CFG_SIZE);
>  	BUILD_BUG_ON(sizeof(struct qla_fdt_layout) != 128);
>  	BUILD_BUG_ON(sizeof(struct qla_flt_header) != 8);
>  	BUILD_BUG_ON(sizeof(struct qla_flt_region) != 16);
> 

The changes themselves look ok, but..

Could the warning be avoided by memset of FCP_PRIO_CFG_HDR_SIZE
before first read_optrom(), and another memset of
"FCP_PRIO_CFG_SIZE - FCP_PRIO_CFG_HDR_SIZE" before second
read_optrom() call?

The reason I ask is that, the kind of "1" element array
declaration in a struct is a common way of mapping a header
followed by N records of some nature. It is a bit sad if we are
moving away from that style and hard computing the structure by hand.

  parent reply	other threads:[~2020-05-11  7:36 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-27  3:02 [PATCH v4 00/11] Fix qla2xxx endianness annotations Bart Van Assche
2020-04-27  3:03 ` [PATCH v4 01/11] qla2xxx: Fix spelling of a variable name Bart Van Assche
2020-04-27  8:10   ` Daniel Wagner
2020-04-27 14:09   ` himanshu.madhani
2020-05-06 12:30   ` Hannes Reinecke
2020-05-11  7:31   ` Arun Easi
2020-04-27  3:03 ` [PATCH v4 02/11] qla2xxx: Suppress two recently introduced compiler warnings Bart Van Assche
2020-04-27  8:15   ` Daniel Wagner
2020-04-27 17:37     ` Bart Van Assche
2020-04-27 18:41     ` Steven Rostedt
2020-04-30  7:29       ` Daniel Wagner
2020-04-27 14:10   ` himanshu.madhani
2020-05-06 13:41   ` Hannes Reinecke
2020-05-11  7:32   ` Arun Easi
2020-04-27  3:03 ` [PATCH v4 03/11] qla2xxx: Sort BUILD_BUG_ON() statements alphabetically Bart Van Assche
2020-04-27  8:16   ` Daniel Wagner
2020-04-27 14:11   ` himanshu.madhani
2020-05-06 13:42   ` Hannes Reinecke
2020-05-11  7:32   ` Arun Easi
2020-04-27  3:03 ` [PATCH v4 04/11] qla2xxx: Add more BUILD_BUG_ON() statements Bart Van Assche
2020-04-27  8:18   ` Daniel Wagner
2020-04-27 14:18   ` himanshu.madhani
2020-05-06 13:42   ` Hannes Reinecke
2020-05-11  7:34   ` Arun Easi
2020-05-11 15:55     ` Bart Van Assche
2020-04-27  3:03 ` [PATCH v4 05/11] qla2xxx: Make a gap in struct qla2xxx_offld_chain explicit Bart Van Assche
2020-04-27  8:26   ` Daniel Wagner
2020-04-27 14:27   ` himanshu.madhani
2020-04-27 17:39     ` Bart Van Assche
2020-05-06 13:43   ` Hannes Reinecke
2020-05-11  7:34   ` Arun Easi
2020-04-27  3:03 ` [PATCH v4 06/11] qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE Bart Van Assche
2020-04-27  8:33   ` Daniel Wagner
2020-04-27 14:28   ` himanshu.madhani
2020-05-06 13:43   ` Hannes Reinecke
2020-05-11  7:36   ` Arun Easi [this message]
2020-05-11 16:04     ` Bart Van Assche
2020-04-27  3:03 ` [PATCH v4 07/11] qla2xxx: Change two hardcoded constants into offsetof() / sizeof() expressions Bart Van Assche
2020-04-27  8:39   ` Daniel Wagner
2020-04-27 14:34   ` himanshu.madhani
2020-05-06 13:45   ` Hannes Reinecke
2020-05-11  7:36   ` Arun Easi
2020-04-27  3:03 ` [PATCH v4 08/11] qla2xxx: Fix the code that reads from mailbox registers Bart Van Assche
2020-04-27  8:41   ` Daniel Wagner
2020-04-27 14:45   ` himanshu.madhani
2020-05-06 14:03   ` Hannes Reinecke
2020-05-11  7:39   ` Arun Easi
2020-05-11 16:07     ` Bart Van Assche
2020-04-27  3:03 ` [PATCH v4 09/11] qla2xxx: Change {RD,WRT}_REG_*() function names from upper case into lower case Bart Van Assche
2020-04-27  8:41   ` Daniel Wagner
2020-04-27 14:53   ` himanshu.madhani
2020-05-11  7:40   ` Arun Easi
2020-05-11 16:11     ` Bart Van Assche
2020-04-27  3:03 ` [PATCH v4 10/11] qla2xxx: Fix endianness annotations in header files Bart Van Assche
2020-04-27 14:57   ` himanshu.madhani
2020-04-28  0:25     ` Finn Thain
2020-04-28 13:55       ` himanshu.madhani
2020-04-27  3:03 ` [PATCH v4 11/11] qla2xxx: Fix endianness annotations in source files Bart Van Assche
2020-04-27 14:59   ` himanshu.madhani

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=alpine.LRH.2.21.9999.2005110035150.23618@irv1user01.caveonetworks.com \
    --to=aeasi@marvell.com \
    --cc=bvanassche@acm.org \
    --cc=dwagner@suse.de \
    --cc=himanshu.madhani@oracle.com \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mwilck@suse.com \
    --cc=njavali@marvell.com \
    --cc=qutran@marvell.com \
    --cc=r.bolshakov@yadro.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.