Skip to content

Commit

Permalink
storvsc: be more picky about scmnd->sc_data_direction
Browse files Browse the repository at this point in the history
Under the 'default' case in scmnd->sc_data_direction we have 3 options:
- DMA_NONE which we handle correctly.
- DMA_BIDIRECTIONAL which is never supposed to be set by SCSI stack.
- Garbage value.

Do WARN() and return -EINVAL in the last two cases. virtio_scsi does
BUG_ON() here but it looks like an overkill.

Reported-by: Radim Krčmář <[email protected]>
Signed-off-by: Vitaly Kuznetsov <[email protected]>
Acked-by: K. Y. Srinivasan <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
  • Loading branch information
vittyvk authored and James Bottomley committed Aug 12, 2015
1 parent 10978e4 commit cb1cf08
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/scsi/storvsc_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,10 +1598,18 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd)
vm_srb->data_in = READ_TYPE;
vm_srb->win8_extension.srb_flags |= SRB_FLAGS_DATA_IN;
break;
default:
case DMA_NONE:
vm_srb->data_in = UNKNOWN_TYPE;
vm_srb->win8_extension.srb_flags |= SRB_FLAGS_NO_DATA_TRANSFER;
break;
default:
/*
* This is DMA_BIDIRECTIONAL or something else we are never
* supposed to see here.
*/
WARN(1, "Unexpected data direction: %d\n",
scmnd->sc_data_direction);
return -EINVAL;
}


Expand Down

0 comments on commit cb1cf08

Please sign in to comment.