Skip to content

Commit 9002b60

Browse files
Bikash HazarikaFishwaldo
authored andcommitted
scsi: qla2xxx: Fix potential NULL pointer dereference
commit 464ea49 upstream. Klocwork tool reported 'cur_dsd' may be dereferenced. Add fix to validate pointer before dereferencing the pointer. 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-3-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>
1 parent 4085aee commit 9002b60

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/scsi/qla2xxx/qla_iocb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,7 +603,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
603603
put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
604604

605605
/* No data transfer */
606-
if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
606+
if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE ||
607+
tot_dsds == 0) {
607608
cmd_pkt->byte_count = cpu_to_le32(0);
608609
return 0;
609610
}

0 commit comments

Comments
 (0)