Skip to content

Commit

Permalink
scsi: qla2xxx: Fix potential NULL pointer dereference
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Bikash Hazarika authored and martinkpetersen committed Jun 15, 2023
1 parent d721b59 commit 464ea49
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/scsi/qla2xxx/qla_iocb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 464ea49

Please sign in to comment.