Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Roman Bolshakov <r.bolshakov@yadro.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 <hmadhani@marvell.com>,
	Quinn Tran <qutran@marvell.com>, Martin Wilck <mwilck@suse.com>,
	Daniel Wagner <dwagner@suse.de>
Subject: Re: [PATCH] qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE
Date: Tue, 14 Apr 2020 14:45:28 +0300	[thread overview]
Message-ID: <20200414114528.GC8042@SPB-NB-133.local> (raw)
In-Reply-To: <6672ed7a-e6d5-b7f4-0ed1-b74e43542ba2@acm.org>

On Mon, Apr 13, 2020 at 08:56:18PM -0700, Bart Van Assche wrote:
> On 2020-04-13 08:30, Roman Bolshakov wrote:
> > On Sun, Apr 05, 2020 at 04:13:39PM -0700, 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);
> >>
> >> ---
> >>  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 f9bad5bd7198..647e67c6ba5e 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*/
> > 
> > A new constant may be introduced to define size of qla_fcp_prio_entry.
> > That would let to drop the magic 32 number here and allow to add one
> > more BUILD_BUG_ON for sizeof(struct qla_fcp_prio_entry).
> 
> The constant FCP_PRIO_CFG_ENTRY_SIZE is only used once, namely in the
> following code:
> 
> 	len = ha->fcp_prio_cfg->num_entries * FCP_PRIO_CFG_ENTRY_SIZE;
> 
> How about removing the definition of FCP_PRIO_CFG_ENTRY_SIZE and
> changing FCP_PRIO_CFG_ENTRY_SIZE in the above calculation into
> sizeof(struct qla_fcp_prio_entry)?
> 

Hi Bart,

I overlooked the FCP_PRIO_CFG_ENTRY_SIZE definition in the hunk :)
Since it's already there, we can just replace 32 with it and add
BUILD_BUG_ON using the definition.

What you propose is also reasonable if used with BUILD_BUG_ON that has
numeric literal for FCP_PRIO_CFG_ENTRY_SIZE.

Thanks,
Roman

      reply	other threads:[~2020-04-14 11:45 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-05 23:13 [PATCH] qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE Bart Van Assche
2020-04-06  7:39 ` Daniel Wagner
2020-04-06 14:54 ` Himanshu Madhani
2020-04-13 15:30 ` Roman Bolshakov
2020-04-14  2:24   ` Martin K. Petersen
2020-04-14 11:49     ` Roman Bolshakov
2020-04-14  3:56   ` Bart Van Assche
2020-04-14 11:45     ` Roman Bolshakov [this message]

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=20200414114528.GC8042@SPB-NB-133.local \
    --to=r.bolshakov@yadro.com \
    --cc=bvanassche@acm.org \
    --cc=dwagner@suse.de \
    --cc=hmadhani@marvell.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 \
    /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