diff options
author | Bart Van Assche <bvanassche@acm.org> | 2019-04-17 23:44:38 +0200 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2019-04-29 23:24:51 +0200 |
commit | 15b7a68c1d030b2365c823730d0eb9257f2aa60e (patch) | |
tree | 2076d18c7fa823873c41d12bb945178b43a30fc9 /drivers/scsi/qla2xxx/qla_dsd.h | |
parent | scsi: qla2xxx: Check the size of firmware data structures at compile time (diff) | |
download | linux-15b7a68c1d030b2365c823730d0eb9257f2aa60e.tar.xz linux-15b7a68c1d030b2365c823730d0eb9257f2aa60e.zip |
scsi: qla2xxx: Introduce the dsd32 and dsd64 data structures
Introduce two structures for the (DMA address, length) combination instead
of using separate structure members for the DMA address and length. This
patch fixes several Coverity complaints about 'cur_dsd' being used to write
outside the bounds of structure members.
Cc: Himanshu Madhani <hmadhani@marvell.com>
Cc: Giridhar Malavali <gmalavali@marvell.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Acked-by: Himanshu Madhani <hmadhani@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_dsd.h')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_dsd.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/scsi/qla2xxx/qla_dsd.h b/drivers/scsi/qla2xxx/qla_dsd.h new file mode 100644 index 000000000000..7479924ba422 --- /dev/null +++ b/drivers/scsi/qla2xxx/qla_dsd.h @@ -0,0 +1,30 @@ +#ifndef _QLA_DSD_H_ +#define _QLA_DSD_H_ + +/* 32-bit data segment descriptor (8 bytes) */ +struct dsd32 { + __le32 address; + __le32 length; +}; + +static inline void append_dsd32(struct dsd32 **dsd, struct scatterlist *sg) +{ + put_unaligned_le32(sg_dma_address(sg), &(*dsd)->address); + put_unaligned_le32(sg_dma_len(sg), &(*dsd)->length); + (*dsd)++; +} + +/* 64-bit data segment descriptor (12 bytes) */ +struct dsd64 { + __le64 address; + __le32 length; +} __packed; + +static inline void append_dsd64(struct dsd64 **dsd, struct scatterlist *sg) +{ + put_unaligned_le64(sg_dma_address(sg), &(*dsd)->address); + put_unaligned_le32(sg_dma_len(sg), &(*dsd)->length); + (*dsd)++; +} + +#endif |