qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE
Subsystems (2)
PATCH 1/1 qla2xxx: Increase the size of struct qla_fcp_prio_cfg to FCP_PRIO_CFG_SIZE
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(-)
drivers/scsi/qla2xxx/qla_fw.h +2 -1
@@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {#define FCP_PRIO_ATTR_PERSIST 0x2uint8_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*/
drivers/scsi/qla2xxx/qla_os.c +1 -0
@@ -7840,6 +7840,7 @@ qla2x00_module_init(void)BUILD_BUG_ON (sizeof (struct vf_evfp_entry_24xx ) !=56 );BUILD_BUG_ON (sizeof (struct qla_flt_region ) !=16 );BUILD_BUG_ON (sizeof (struct qla_flt_header ) !=8 ); +BUILD_BUG_ON (sizeof (struct qla_fcp_prio_cfg ) !=FCP_PRIO_CFG_SIZE );/* Allocate cache for SRBs. */ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
Hi Bart,
Quoted 11 lines · Bart Van Assche
This patch fixes the following Coverity complaint without changing any functionality:
CID 337793 (#1 of 1): Wrong size argument (
SIZEOF_MISMATCH)suspicious_sizeof: Passing argumentha->fcp_prio_cfgof type structqla_fcp_prio_cfg* and argument 32768UL to function memset is suspicious because a multiple of sizeof (structqla_fcp_prio_cfg) /*48*/ is expected.
memset(ha->fcp_prio_cfg, 0, FCP_PRIO_CFG_SIZE);
Quoted 7 lines
Cc Nilesh Javali <[email protected]>Cc Himanshu Madhani <[email protected]>Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>
Looks good to me.
Thanks,
Daniel
Quoted 44 lines · Bart Van Assche
This patch fixes the following Coverity complaint without changing any functionality:
CID 337793 (#1 of 1): Wrong size argument (
SIZEOF_MISMATCH)suspicious_sizeof: Passing argumentha->fcp_prio_cfgof type structqla_fcp_prio_cfg* and argument 32768UL to function memset is suspicious because a multiple of sizeof (structqla_fcp_prio_cfg) /*48*/ is expected.
memset(ha->fcp_prio_cfg, 0, FCP_PRIO_CFG_SIZE);Cc Nilesh Javali <[email protected]>Cc Himanshu Madhani <[email protected]>Cc Quinn Tran <[email protected]>Cc Martin Wilck <[email protected]>Cc Daniel Wagner <[email protected]>Cc Roman Bolshakov <[email protected]>Signed-off-by Bart Van Assche <[email protected]>--- drivers/scsi/qla2xxx/qla_fw.h | 3 ++- drivers/scsi/qla2xxx/qla_os.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)drivers/scsi/qla2xxx/qla_fw.h +2
-1@@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {#define FCP_PRIO_ATTR_PERSIST 0x2uint8_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*/ drivers/scsi/qla2xxx/qla_os.c +0
-0
drivers/scsi/qla2xxx/qla_os.c qla2x00_module_init(void) · line 7846
Quoted 7 lines
drivers/scsi/qla2xxx/qla_os.c +1
-0@@ -7840,6 +7840,7 @@ qla2x00_module_init(void)BUILD_BUG_ON (sizeof (struct vf_evfp_entry_24xx ) !=56 );BUILD_BUG_ON (sizeof (struct qla_flt_region ) !=16 );BUILD_BUG_ON (sizeof (struct qla_flt_header ) !=8 ); +BUILD_BUG_ON (sizeof (struct qla_fcp_prio_cfg ) !=FCP_PRIO_CFG_SIZE );/* Allocate cache for SRBs. */ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
Signature · 1 line
Himanshu
Quoted 21 lines · Bart Van Assche
This patch fixes the following Coverity complaint without changing any functionality:
CID 337793 (#1 of 1): Wrong size argument (
SIZEOF_MISMATCH)suspicious_sizeof: Passing argumentha->fcp_prio_cfgof type structqla_fcp_prio_cfg* and argument 32768UL to function memset is suspicious because a multiple of sizeof (structqla_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(-)drivers/scsi/qla2xxx/qla_fw.h +0
-0
drivers/scsi/qla2xxx/qla_fw.h struct qla_fcp_prio_cfg { · line 2225
Quoted 10 lines
drivers/scsi/qla2xxx/qla_fw.h +2
-1@@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {#define FCP_PRIO_ATTR_PERSIST 0x2uint8_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*/
Hi Bart,
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).
Besides that,
drivers/scsi/qla2xxx/qla_os.c qla2x00_module_init(void) · line 7846
Quoted 12 lines
drivers/scsi/qla2xxx/qla_os.c +1
-0@@ -7840,6 +7840,7 @@ qla2x00_module_init(void)BUILD_BUG_ON (sizeof (struct vf_evfp_entry_24xx ) !=56 );BUILD_BUG_ON (sizeof (struct qla_flt_region ) !=16 );BUILD_BUG_ON (sizeof (struct qla_flt_header ) !=8 ); +BUILD_BUG_ON (sizeof (struct qla_fcp_prio_cfg ) !=FCP_PRIO_CFG_SIZE );/* Allocate cache for SRBs. */ srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
Thanks,
Roman
Roman,
Quoted 11 lines
drivers/scsi/qla2xxx/qla_fw.h struct qla_fcp_prio_cfg { · line 2225
Quoted 7 lines
drivers/scsi/qla2xxx/qla_fw.h +2
-1-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 moreBUILD_BUG_ONforsizeof(struct qla_fcp_prio_entry).
I agree that additional sanity testing here would be nice.
I wonder what the firmware interface says about the runt entry?
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Quoted 9 lines · Martin K. Petersen
Roman,
Quoted 6 lines
Quoted 6 lines
drivers/scsi/qla2xxx/qla_fw.h +2
-1-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 ]; };
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
#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 moreBUILD_BUG_ONforsizeof(struct qla_fcp_prio_entry).I wonder what the firmware interface says about the runt entry?
Hi Martin,
NVRAM and Option ROM contents/layout doesn't seem to be a part of the FW spec.
Roman
Quoted 31 lines · Roman Bolshakov
Quoted 30 lines · Bart Van Assche
This patch fixes the following Coverity complaint without changing any functionality:
CID 337793 (#1 of 1): Wrong size argument (
SIZEOF_MISMATCH)suspicious_sizeof: Passing argumentha->fcp_prio_cfgof type structqla_fcp_prio_cfg* and argument 32768UL to function memset is suspicious because a multiple of sizeof (structqla_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(-)drivers/scsi/qla2xxx/qla_fw.h +2
-1@@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {#define FCP_PRIO_ATTR_PERSIST 0x2uint8_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 ]; };
Quoted 7 lines
drivers/scsi/qla2xxx/qla_fw.h struct qla_fcp_prio_cfg { · line 2225
Quoted 1 line
drivers/scsi/qla2xxx/qla_fw.h +0
-0#define FCP_PRIO_CFG_SIZE (32*1024)/* fcp prio data per port*/ Hi Bart,
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 moreBUILD_BUG_ONforsizeof(struct qla_fcp_prio_entry).
Hi Roman,
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)?
Thanks,
Bart.
Quoted 38 lines · Bart Van Assche
Quoted 31 lines · Roman Bolshakov
Quoted 30 lines · Bart Van Assche
This patch fixes the following Coverity complaint without changing any functionality:
CID 337793 (#1 of 1): Wrong size argument (
SIZEOF_MISMATCH)suspicious_sizeof: Passing argumentha->fcp_prio_cfgof type structqla_fcp_prio_cfg* and argument 32768UL to function memset is suspicious because a multiple of sizeof (structqla_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(-)drivers/scsi/qla2xxx/qla_fw.h +2
-1@@ -2217,8 +2217,9 @@ struct qla_fcp_prio_cfg {#define FCP_PRIO_ATTR_PERSIST 0x2uint8_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 ]; };Quoted 5 lines
drivers/scsi/qla2xxx/qla_fw.h struct qla_fcp_prio_cfg { · line 2225
Quoted 1 line
drivers/scsi/qla2xxx/qla_fw.h +0
-0#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 moreBUILD_BUG_ONforsizeof(struct qla_fcp_prio_entry).
Quoted 9 lines
The constant
FCP_PRIO_CFG_ENTRY_SIZEis 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_SIZEand changingFCP_PRIO_CFG_ENTRY_SIZEin the above calculation intosizeof(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