scsi: qla2xxx: Correct the index of array
commit b1b9d3825df4c757d653d0b1df66f084835db9c3 upstream. Klocwork reported array 'port_dstate_str' of size 10 may use index value(s) 10..15. Add a fix to correct the index of array. Cc: stable@vger.kernel.org Signed-off-by: Bikash Hazarika <bhazarika@marvell.com> Signed-off-by: Nilesh Javali <njavali@marvell.com> Link: https://lore.kernel.org/r/20230607113843.37185-8-njavali@marvell.com Reviewed-by: Himanshu Madhani <himanshu.madhani@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
e466930717
commit
b88b1241fb
@ -109,11 +109,13 @@ qla2x00_set_fcport_disc_state(fc_port_t *fcport, int state)
|
|||||||
{
|
{
|
||||||
int old_val;
|
int old_val;
|
||||||
uint8_t shiftbits, mask;
|
uint8_t shiftbits, mask;
|
||||||
|
uint8_t port_dstate_str_sz;
|
||||||
|
|
||||||
/* This will have to change when the max no. of states > 16 */
|
/* This will have to change when the max no. of states > 16 */
|
||||||
shiftbits = 4;
|
shiftbits = 4;
|
||||||
mask = (1 << shiftbits) - 1;
|
mask = (1 << shiftbits) - 1;
|
||||||
|
|
||||||
|
port_dstate_str_sz = sizeof(port_dstate_str) / sizeof(char *);
|
||||||
fcport->disc_state = state;
|
fcport->disc_state = state;
|
||||||
while (1) {
|
while (1) {
|
||||||
old_val = atomic_read(&fcport->shadow_disc_state);
|
old_val = atomic_read(&fcport->shadow_disc_state);
|
||||||
@ -121,7 +123,8 @@ qla2x00_set_fcport_disc_state(fc_port_t *fcport, int state)
|
|||||||
old_val, (old_val << shiftbits) | state)) {
|
old_val, (old_val << shiftbits) | state)) {
|
||||||
ql_dbg(ql_dbg_disc, fcport->vha, 0x2134,
|
ql_dbg(ql_dbg_disc, fcport->vha, 0x2134,
|
||||||
"FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n",
|
"FCPort %8phC disc_state transition: %s to %s - portid=%06x.\n",
|
||||||
fcport->port_name, port_dstate_str[old_val & mask],
|
fcport->port_name, (old_val & mask) < port_dstate_str_sz ?
|
||||||
|
port_dstate_str[old_val & mask] : "Unknown",
|
||||||
port_dstate_str[state], fcport->d_id.b24);
|
port_dstate_str[state], fcport->d_id.b24);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user