Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[SCSI] csiostor: off by one error

We need to store PROTO_ERR_IMPL_LOGO (26) things here, but the
first element isn't used so the array should have 27 elements.
This matches fwevt_to_rnevt[] which has 27 elements.

The patch solves a Smatch static checker warning on my system:
drivers/scsi/csiostor/csio_rnode.c:880 csio_rnode_fwevt_handler()
error: buffer overflow '(rn)->stats.n_evt_fw' 26 <= 26

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Naresh Kumar Inna <naresh@chelsio.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>

authored by

Dan Carpenter and committed by
James Bottomley
4f8d1bd2 0a7d1d36

+2 -2
+1 -1
drivers/scsi/csiostor/csio_lnode.h
··· 114 114 uint32_t n_rnode_match; /* matched rnode */ 115 115 uint32_t n_dev_loss_tmo; /* Device loss timeout */ 116 116 uint32_t n_fdmi_err; /* fdmi err */ 117 - uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO]; /* fw events */ 117 + uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1]; /* fw events */ 118 118 enum csio_ln_ev n_evt_sm[CSIO_LNE_MAX_EVENT]; /* State m/c events */ 119 119 uint32_t n_rnode_alloc; /* rnode allocated */ 120 120 uint32_t n_rnode_free; /* rnode freed */
+1 -1
drivers/scsi/csiostor/csio_rnode.h
··· 63 63 uint32_t n_err_nomem; /* error nomem */ 64 64 uint32_t n_evt_unexp; /* unexpected event */ 65 65 uint32_t n_evt_drop; /* unexpected event */ 66 - uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO]; /* fw events */ 66 + uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1]; /* fw events */ 67 67 enum csio_rn_ev n_evt_sm[CSIO_RNFE_MAX_EVENT]; /* State m/c events */ 68 68 uint32_t n_lun_rst; /* Number of resets of 69 69 * of LUNs under this