aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/target/target_core_transport.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/target/target_core_transport.c')
-rw-r--r--drivers/target/target_core_transport.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 4a787a0ab068..895969650a27 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -3932,7 +3932,6 @@ static int transport_allocate_data_tasks(
struct scatterlist *sgl,
unsigned int sgl_nents)
{
- unsigned char *cdb = NULL;
struct se_task *task;
struct se_device *dev = cmd->se_dev;
unsigned long flags;
@@ -3959,14 +3958,17 @@ static int transport_allocate_data_tasks(
task->task_sectors = min(sectors, dev_max_sectors);
task->task_size = task->task_sectors * sector_size;
- cdb = dev->transport->get_cdb(task);
- BUG_ON(!cdb);
+ if (dev->transport->get_cdb) {
+ unsigned char *cdb = dev->transport->get_cdb(task);
- memcpy(cdb, cmd->t_task_cdb,
- scsi_command_size(cmd->t_task_cdb));
+ memcpy(cdb, cmd->t_task_cdb,
+ scsi_command_size(cmd->t_task_cdb));
+
+ /* Update new cdb with updated lba/sectors */
+ cmd->transport_split_cdb(task->task_lba,
+ task->task_sectors, cdb);
+ }
- /* Update new cdb with updated lba/sectors */
- cmd->transport_split_cdb(task->task_lba, task->task_sectors, cdb);
/*
* This now assumes that passed sg_ents are in PAGE_SIZE chunks
* in order to calculate the number per task SGL entries
@@ -4021,7 +4023,6 @@ static int
transport_allocate_control_task(struct se_cmd *cmd)
{
struct se_device *dev = cmd->se_dev;
- unsigned char *cdb;
struct se_task *task;
unsigned long flags;
@@ -4029,10 +4030,11 @@ transport_allocate_control_task(struct se_cmd *cmd)
if (!task)
return -ENOMEM;
- cdb = dev->transport->get_cdb(task);
- BUG_ON(!cdb);
- memcpy(cdb, cmd->t_task_cdb,
- scsi_command_size(cmd->t_task_cdb));
+ if (dev->transport->get_cdb) {
+ unsigned char *cdb = dev->transport->get_cdb(task);
+
+ memcpy(cdb, cmd->t_task_cdb, scsi_command_size(cmd->t_task_cdb));
+ }
task->task_sg = kmalloc(sizeof(struct scatterlist) * cmd->t_data_nents,
GFP_KERNEL);

Privacy Policy