Skip to content

Commit 464ea49

Browse files
Bikash Hazarikamartinkpetersen
authored andcommitted
scsi: qla2xxx: Fix potential NULL pointer dereference
Klocwork tool reported 'cur_dsd' may be dereferenced. Add fix to validate pointer before dereferencing the pointer. Cc: [email protected] Signed-off-by: Bikash Hazarika <[email protected]> Signed-off-by: Nilesh Javali <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Himanshu Madhani <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d721b59 commit 464ea49

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
@@ -607,7 +607,8 @@ qla24xx_build_scsi_type_6_iocbs(srb_t *sp, struct cmd_type_6 *cmd_pkt,
607607
put_unaligned_le32(COMMAND_TYPE_6, &cmd_pkt->entry_type);
608608

609609
/* No data transfer */
610-
if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
610+
if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE ||
611+
tot_dsds == 0) {
611612
cmd_pkt->byte_count = cpu_to_le32(0);
612613
return 0;
613614
}

0 commit comments

Comments
 (0)