Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 609234e3 authored by Wei Yongjun's avatar Wei Yongjun Committed by Nicholas Bellinger
Browse files

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: default avatarWei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 7875f179
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -197,10 +197,10 @@ int target_scsi2_reservation_release(struct se_cmd *cmd)
{
{
	struct se_device *dev = cmd->se_dev;
	struct se_device *dev = cmd->se_dev;
	struct se_session *sess = cmd->se_sess;
	struct se_session *sess = cmd->se_sess;
	struct se_portal_group *tpg = sess->se_tpg;
	struct se_portal_group *tpg;
	int ret = 0, rc;
	int ret = 0, rc;


	if (!sess || !tpg)
	if (!sess || !sess->se_tpg)
		goto out;
		goto out;
	rc = target_check_scsi2_reservation_conflict(cmd);
	rc = target_check_scsi2_reservation_conflict(cmd);
	if (rc == 1)
	if (rc == 1)
@@ -228,6 +228,7 @@ int target_scsi2_reservation_release(struct se_cmd *cmd)
		dev->dev_res_bin_isid = 0;
		dev->dev_res_bin_isid = 0;
		dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID;
		dev->dev_flags &= ~DF_SPC2_RESERVATIONS_WITH_ISID;
	}
	}
	tpg = sess->se_tpg;
	pr_debug("SCSI-2 Released reservation for %s LUN: %u ->"
	pr_debug("SCSI-2 Released reservation for %s LUN: %u ->"
		" MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
		" MAPPED LUN: %u for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
		cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun,
		cmd->se_lun->unpacked_lun, cmd->se_deve->mapped_lun,
@@ -245,7 +246,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
{
{
	struct se_device *dev = cmd->se_dev;
	struct se_device *dev = cmd->se_dev;
	struct se_session *sess = cmd->se_sess;
	struct se_session *sess = cmd->se_sess;
	struct se_portal_group *tpg = sess->se_tpg;
	struct se_portal_group *tpg;
	int ret = 0, rc;
	int ret = 0, rc;


	if ((cmd->t_task_cdb[1] & 0x01) &&
	if ((cmd->t_task_cdb[1] & 0x01) &&
@@ -260,7 +261,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
	 * This is currently the case for target_core_mod passthrough struct se_cmd
	 * This is currently the case for target_core_mod passthrough struct se_cmd
	 * ops
	 * ops
	 */
	 */
	if (!sess || !tpg)
	if (!sess || !sess->se_tpg)
		goto out;
		goto out;
	rc = target_check_scsi2_reservation_conflict(cmd);
	rc = target_check_scsi2_reservation_conflict(cmd);
	if (rc == 1)
	if (rc == 1)
@@ -272,6 +273,7 @@ int target_scsi2_reservation_reserve(struct se_cmd *cmd)
	}
	}


	ret = 0;
	ret = 0;
	tpg = sess->se_tpg;
	spin_lock(&dev->dev_reservation_lock);
	spin_lock(&dev->dev_reservation_lock);
	if (dev->dev_reserved_node_acl &&
	if (dev->dev_reserved_node_acl &&
	   (dev->dev_reserved_node_acl != sess->se_node_acl)) {
	   (dev->dev_reserved_node_acl != sess->se_node_acl)) {