> On Jun 7, 2023, at 4:38 AM, Nilesh Javali <njavali@xxxxxxxxxxx> wrote: > > From: Bikash Hazarika <bhazarika@xxxxxxxxxxx> > > Klocwork tool reported 'cur_dsd' may be dereferenced. > Add fix to validate pointer before dereferencing > the pointer. > > Cc: stable@xxxxxxxxxxxxxxx > Signed-off-by: Bikash Hazarika <bhazarika@xxxxxxxxxxx> > Signed-off-by: Nilesh Javali <njavali@xxxxxxxxxxx> > --- > v2: > - check tot_dsds to suppress kw warning. > > drivers/scsi/qla2xxx/qla_iocb.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c > index 6acfdcc48b16..a1675f056a5c 100644 > --- a/drivers/scsi/qla2xxx/qla_iocb.c > +++ b/drivers/scsi/qla2xxx/qla_iocb.c > @@ -607,7 +607,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt, > put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type); > > /* No data transfer */ > - if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { > + if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE || > + tot_dsds == 0) { > cmd_pkt->byte_count = cpu_to_le32(0); > return 0; > } > -- > 2.23.1 > Reviewed-by: Himanshu Madhani <himanshu.madhani@xxxxxxxxxx> -- Himanshu Madhani Oracle Linux Engineering