@@ -562,8 +562,6 @@ tcmu_get_block_page(struct tcmu_dev *udev, uint32_t dbi)
562
562
563
563
static inline void tcmu_free_cmd (struct tcmu_cmd * tcmu_cmd )
564
564
{
565
- if (tcmu_cmd -> se_cmd )
566
- tcmu_cmd -> se_cmd -> priv = NULL ;
567
565
kfree (tcmu_cmd -> dbi );
568
566
kmem_cache_free (tcmu_cmd_cache , tcmu_cmd );
569
567
}
@@ -1174,11 +1172,12 @@ tcmu_queue_cmd(struct se_cmd *se_cmd)
1174
1172
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE ;
1175
1173
1176
1174
mutex_lock (& udev -> cmdr_lock );
1177
- se_cmd -> priv = tcmu_cmd ;
1178
1175
if (!(se_cmd -> transport_state & CMD_T_ABORTED ))
1179
1176
ret = queue_cmd_ring (tcmu_cmd , & scsi_ret );
1180
1177
if (ret < 0 )
1181
1178
tcmu_free_cmd (tcmu_cmd );
1179
+ else
1180
+ se_cmd -> priv = tcmu_cmd ;
1182
1181
mutex_unlock (& udev -> cmdr_lock );
1183
1182
return scsi_ret ;
1184
1183
}
@@ -1241,6 +1240,7 @@ tcmu_tmr_notify(struct se_device *se_dev, enum tcm_tmreq_table tmf,
1241
1240
1242
1241
list_del_init (& cmd -> queue_entry );
1243
1242
tcmu_free_cmd (cmd );
1243
+ se_cmd -> priv = NULL ;
1244
1244
target_complete_cmd (se_cmd , SAM_STAT_TASK_ABORTED );
1245
1245
unqueued = true;
1246
1246
}
@@ -1332,6 +1332,7 @@ static void tcmu_handle_completion(struct tcmu_cmd *cmd, struct tcmu_cmd_entry *
1332
1332
}
1333
1333
1334
1334
done :
1335
+ se_cmd -> priv = NULL ;
1335
1336
if (read_len_valid ) {
1336
1337
pr_debug ("read_len = %d\n" , read_len );
1337
1338
target_complete_cmd_with_length (cmd -> se_cmd ,
@@ -1478,6 +1479,7 @@ static void tcmu_check_expired_queue_cmd(struct tcmu_cmd *cmd)
1478
1479
se_cmd = cmd -> se_cmd ;
1479
1480
tcmu_free_cmd (cmd );
1480
1481
1482
+ se_cmd -> priv = NULL ;
1481
1483
target_complete_cmd (se_cmd , SAM_STAT_TASK_SET_FULL );
1482
1484
}
1483
1485
@@ -1592,6 +1594,7 @@ static void run_qfull_queue(struct tcmu_dev *udev, bool fail)
1592
1594
* removed then LIO core will do the right thing and
1593
1595
* fail the retry.
1594
1596
*/
1597
+ tcmu_cmd -> se_cmd -> priv = NULL ;
1595
1598
target_complete_cmd (tcmu_cmd -> se_cmd , SAM_STAT_BUSY );
1596
1599
tcmu_free_cmd (tcmu_cmd );
1597
1600
continue ;
@@ -1605,6 +1608,7 @@ static void run_qfull_queue(struct tcmu_dev *udev, bool fail)
1605
1608
* Ignore scsi_ret for now. target_complete_cmd
1606
1609
* drops it.
1607
1610
*/
1611
+ tcmu_cmd -> se_cmd -> priv = NULL ;
1608
1612
target_complete_cmd (tcmu_cmd -> se_cmd ,
1609
1613
SAM_STAT_CHECK_CONDITION );
1610
1614
tcmu_free_cmd (tcmu_cmd );
@@ -2212,6 +2216,7 @@ static void tcmu_reset_ring(struct tcmu_dev *udev, u8 err_level)
2212
2216
if (!test_bit (TCMU_CMD_BIT_EXPIRED , & cmd -> flags )) {
2213
2217
WARN_ON (!cmd -> se_cmd );
2214
2218
list_del_init (& cmd -> queue_entry );
2219
+ cmd -> se_cmd -> priv = NULL ;
2215
2220
if (err_level == 1 ) {
2216
2221
/*
2217
2222
* Userspace was not able to start the
0 commit comments