Message ID | 1435248731-29085-1-git-send-email-vkuznets@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogVml0YWx5IEt1em5ldHNv diBbbWFpbHRvOnZrdXpuZXRzQHJlZGhhdC5jb21dDQo+IFNlbnQ6IFRodXJzZGF5LCBKdW5lIDI1 LCAyMDE1IDk6MTIgQU0NCj4gVG86IGxpbnV4LXNjc2lAdmdlci5rZXJuZWwub3JnDQo+IENjOiBM b25nIExpOyBLWSBTcmluaXZhc2FuOyBIYWl5YW5nIFpoYW5nOyBKYW1lcyBFLkouIEJvdHRvbWxl eTsNCj4gZGV2ZWxAbGludXhkcml2ZXJwcm9qZWN0Lm9yZzsgbGludXgta2VybmVsQHZnZXIua2Vy bmVsLm9yZzsgUmFkaW0gS3LEjW3DocWZDQo+IFN1YmplY3Q6IFtQQVRDSF0gc2NzaTogc3RvcnZz YzogYmUgbW9yZSBwaWNreSBhYm91dCBzY21uZC0NCj4gPnNjX2RhdGFfZGlyZWN0aW9uDQo+IA0K PiBVbmRlciB0aGUgJ2RlZmF1bHQnIGNhc2UgaW4gc2NtbmQtPnNjX2RhdGFfZGlyZWN0aW9uIHdl IGhhdmUgMyBvcHRpb25zOg0KPiAtIERNQV9OT05FIHdoaWNoIHdlIGhhbmRsZSBjb3JyZWN0bHku DQo+IC0gRE1BX0JJRElSRUNUSU9OQUwgd2hpY2ggaXMgbmV2ZXIgc3VwcG9zZWQgdG8gYmUgc2V0 IGJ5IFNDU0kgc3RhY2suDQo+IC0gR2FyYmFnZSB2YWx1ZS4NCj4gDQo+IERvIFdBUk4oKSBhbmQg cmV0dXJuIC1FSU5WQUwgaW4gdGhlIGxhc3QgdHdvIGNhc2VzLiB2aXJ0aW9fc2NzaSBkb2VzDQo+ IEJVR19PTigpIGhlcmUgYnV0IGl0IGxvb2tzIGxpa2UgYW4gb3ZlcmtpbGwuDQo+IA0KPiBSZ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8PQ0KPiBTUkJfRkxBR1NfTk9fREFU QV9UUkFOU0ZFUjsNCj4gIAkJYnJlYWs7DQo+ICsJZGVmYXVsdDoNCj4gKwkJLyoNCj4gKwkJICog VGhpcyBpcyBETUFfQklESVJFQ1RJT05BTCBvciBzb21ldGhpbmcgZWxzZSB3ZSBhcmUNCj4gbmV2 ZXINCj4gKwkJICogc3VwcG9zZWQgdG8gc2VlIGhlcmUuDQo+ICsJCSAqLw0KPiArCQlXQVJOKDEs ICJVbmV4cGVjdGVkIGRhdGEgZGlyZWN0aW9uOiAlZFxuIiwNCj4gKwkJICAgICBzY21uZC0+c2Nf ZGF0YV9kaXJlY3Rpb24pOw0KPiArCQlyZXR1cm4gLUVJTlZBTDsNCj4gIAl9DQo+IA0KPiANCj4g LS0NCj4gMi40LjMNCg0K -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
KY Srinivasan <kys@microsoft.com> writes: >> -----Original Message----- >> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com] >> Sent: Thursday, June 25, 2015 9:12 AM >> To: linux-scsi@vger.kernel.org >> Cc: Long Li; KY Srinivasan; Haiyang Zhang; James E.J. Bottomley; >> devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Radim Kr?má? >> Subject: [PATCH] scsi: storvsc: be more picky about scmnd- >> >sc_data_direction >> >> 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á? <rkrcmar@redhat.com> >> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> > Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> Sorry for the ping but it seems the fix never made it to scsi tree... >> --- >> drivers/scsi/storvsc_drv.c | 10 +++++++++- >> 1 file changed, 9 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c >> index 3c6584f..61f4855 100644 >> --- a/drivers/scsi/storvsc_drv.c >> +++ b/drivers/scsi/storvsc_drv.c >> @@ -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; >> } >> >> >> -- >> 2.4.3
diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c index 3c6584f..61f4855 100644 --- a/drivers/scsi/storvsc_drv.c +++ b/drivers/scsi/storvsc_drv.c @@ -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; }
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á? <rkrcmar@redhat.com> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com> --- drivers/scsi/storvsc_drv.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)