From 8eef92a47449c8b4927806a1518b5a442f0d2e3b Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Mon, 24 Oct 2011 13:35:37 -0700 Subject: [PATCH] --- yaml --- r: 274333 b: refs/heads/master c: 8cd79f24350826b81e16990d9e12bc878e67d385 h: refs/heads/master i: 274331: d69e792ecca72b870ed8bd9a643a68b0303c61d4 v: v3 --- [refs] | 2 +- trunk/drivers/target/loopback/tcm_loop.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/[refs] b/[refs] index bf7299f326b6..0b55e89ef5d1 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: c9abb9bb0b8451588509192bd53005d65c02986c +refs/heads/master: 8cd79f24350826b81e16990d9e12bc878e67d385 diff --git a/trunk/drivers/target/loopback/tcm_loop.c b/trunk/drivers/target/loopback/tcm_loop.c index b15d8cbf630b..3c9c318f66ed 100644 --- a/trunk/drivers/target/loopback/tcm_loop.c +++ b/trunk/drivers/target/loopback/tcm_loop.c @@ -174,6 +174,24 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) sgl_bidi = sdb->table.sgl; sgl_bidi_count = sdb->table.nents; } + /* + * Because some userspace code via scsi-generic do not memset their + * associated read buffers, go ahead and do that here for type + * SCF_SCSI_CONTROL_SG_IO_CDB. Also note that this is currently + * guaranteed to be a single SGL for SCF_SCSI_CONTROL_SG_IO_CDB + * by target core in transport_generic_allocate_tasks() -> + * transport_generic_cmd_sequencer(). + */ + if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB && + se_cmd->data_direction == DMA_FROM_DEVICE) { + struct scatterlist *sg = scsi_sglist(sc); + unsigned char *buf = kmap(sg_page(sg)) + sg->offset; + + if (buf != NULL) { + memset(buf, 0, sg->length); + kunmap(sg_page(sg)); + } + } /* Tell the core about our preallocated memory */ ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc),