diff options
Diffstat (limited to 'drivers/target/loopback')
-rw-r--r-- | drivers/target/loopback/tcm_loop.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index b15d8cbf630b..3c9c318f66ed 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c | |||
@@ -174,6 +174,24 @@ static int tcm_loop_new_cmd_map(struct se_cmd *se_cmd) | |||
174 | sgl_bidi = sdb->table.sgl; | 174 | sgl_bidi = sdb->table.sgl; |
175 | sgl_bidi_count = sdb->table.nents; | 175 | sgl_bidi_count = sdb->table.nents; |
176 | } | 176 | } |
177 | /* | ||
178 | * Because some userspace code via scsi-generic do not memset their | ||
179 | * associated read buffers, go ahead and do that here for type | ||
180 | * SCF_SCSI_CONTROL_SG_IO_CDB. Also note that this is currently | ||
181 | * guaranteed to be a single SGL for SCF_SCSI_CONTROL_SG_IO_CDB | ||
182 | * by target core in transport_generic_allocate_tasks() -> | ||
183 | * transport_generic_cmd_sequencer(). | ||
184 | */ | ||
185 | if (se_cmd->se_cmd_flags & SCF_SCSI_CONTROL_SG_IO_CDB && | ||
186 | se_cmd->data_direction == DMA_FROM_DEVICE) { | ||
187 | struct scatterlist *sg = scsi_sglist(sc); | ||
188 | unsigned char *buf = kmap(sg_page(sg)) + sg->offset; | ||
189 | |||
190 | if (buf != NULL) { | ||
191 | memset(buf, 0, sg->length); | ||
192 | kunmap(sg_page(sg)); | ||
193 | } | ||
194 | } | ||
177 | 195 | ||
178 | /* Tell the core about our preallocated memory */ | 196 | /* Tell the core about our preallocated memory */ |
179 | ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), | 197 | ret = transport_generic_map_mem_to_cmd(se_cmd, scsi_sglist(sc), |