From: Christoph Hellwig Date: Tue, 21 Feb 2017 09:04:55 +0000 (+0100) Subject: scsi: zero per-cmd driver data before each I/O X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ee5242360424b9b967454e9183767323d10cf985;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git scsi: zero per-cmd driver data before each I/O Without this drivers that don't clear the state themselves can see off effects. For example Hyper-V VMs using the storvsc driver will often hang during boot due to uncleared Test Unit Ready failures. Fixes: e9c787e6 ("scsi: allocate scsi_cmnd structures as part of struct request") Signed-off-by: Christoph Hellwig Reported-by: Dexuan Cui Tested-by: Dexuan Cui Reviewed-by: Bart Van Assche Signed-off-by: Jens Axboe --- diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 912fbc3b4543..3e32dc954c3c 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1167,7 +1167,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd) /* zero out the cmd, except for the embedded scsi_request */ memset((char *)cmd + sizeof(cmd->req), 0, - sizeof(*cmd) - sizeof(cmd->req)); + sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size); cmd->device = dev; cmd->sense_buffer = buf;