Commit 609234e3b6d69315b5cd511b66435d733204e779

Authored by Wei Yongjun
Committed by Nicholas Bellinger
1 parent 7875f17908

target: move the dereference below the NULL test

The dereference should be moved below the NULL test.

spatch with a semantic match is used to found this.
(http://coccinelle.lip6.fr/)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

Showing 1 changed file with 6 additions and 4 deletions Side-by-side Diff

drivers/target/target_core_pr.c
... ... @@ -197,10 +197,10 @@
197 197 {
198 198 struct se_device *dev = cmd->se_dev;
199 199 struct se_session *sess = cmd->se_sess;
200   - struct se_portal_group *tpg = sess->se_tpg;
  200 + struct se_portal_group *tpg;
201 201 int ret = 0, rc;
202 202  
203   - if (!sess || !tpg)
  203 + if (!sess || !sess->se_tpg)
204 204 goto out;
205 205 rc = target_check_scsi2_reservation_conflict(cmd);
206 206 if (rc == 1)
... ... @@ -228,6 +228,7 @@
228 228 dev->dev_res_bin_isid = 0;
229 229 dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID;
230 230 }
  231 + tpg = sess->se_tpg;
231 232 pr_debug("SCSI-2 Released reservation for %s LUN: %u ->"
232 233 " MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
233 234 cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun,
... ... @@ -245,7 +246,7 @@
245 246 {
246 247 struct se_device *dev = cmd->se_dev;
247 248 struct se_session *sess = cmd->se_sess;
248   - struct se_portal_group *tpg = sess->se_tpg;
  249 + struct se_portal_group *tpg;
249 250 int ret = 0, rc;
250 251  
251 252 if ((cmd->t_task_cdb[1] & 0x01) &&
... ... @@ -260,7 +261,7 @@
260 261 * This is currently the case for target_core_mod passthrough struct se_cmd
261 262 * ops
262 263 */
263   - if (!sess || !tpg)
  264 + if (!sess || !sess->se_tpg)
264 265 goto out;
265 266 rc = target_check_scsi2_reservation_conflict(cmd);
266 267 if (rc == 1)
... ... @@ -272,6 +273,7 @@
272 273 }
273 274  
274 275 ret = 0;
  276 + tpg = sess->se_tpg;
275 277 spin_lock(&dev->dev_reservation_lock);
276 278 if (dev->dev_reserved_node_acl &&
277 279 (dev->dev_reserved_node_acl != sess->se_node_acl)) {