diff options
| -rw-r--r-- | drivers/target/target_core_pr.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c index 2f5d77932c80..3013287a2aaa 100644 --- a/drivers/target/target_core_pr.c +++ b/drivers/target/target_core_pr.c | |||
| @@ -2009,7 +2009,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
| 2009 | struct t10_reservation *pr_tmpl = &dev->t10_pr; | 2009 | struct t10_reservation *pr_tmpl = &dev->t10_pr; |
| 2010 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; | 2010 | unsigned char isid_buf[PR_REG_ISID_LEN], *isid_ptr = NULL; |
| 2011 | sense_reason_t ret = TCM_NO_SENSE; | 2011 | sense_reason_t ret = TCM_NO_SENSE; |
| 2012 | int pr_holder = 0; | 2012 | int pr_holder = 0, type; |
| 2013 | 2013 | ||
| 2014 | if (!se_sess || !se_lun) { | 2014 | if (!se_sess || !se_lun) { |
| 2015 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); | 2015 | pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); |
| @@ -2131,6 +2131,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
| 2131 | ret = TCM_RESERVATION_CONFLICT; | 2131 | ret = TCM_RESERVATION_CONFLICT; |
| 2132 | goto out; | 2132 | goto out; |
| 2133 | } | 2133 | } |
| 2134 | type = pr_reg->pr_res_type; | ||
| 2134 | 2135 | ||
| 2135 | spin_lock(&pr_tmpl->registration_lock); | 2136 | spin_lock(&pr_tmpl->registration_lock); |
| 2136 | /* | 2137 | /* |
| @@ -2161,6 +2162,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
| 2161 | * Release the calling I_T Nexus registration now.. | 2162 | * Release the calling I_T Nexus registration now.. |
| 2162 | */ | 2163 | */ |
| 2163 | __core_scsi3_free_registration(cmd->se_dev, pr_reg, NULL, 1); | 2164 | __core_scsi3_free_registration(cmd->se_dev, pr_reg, NULL, 1); |
| 2165 | pr_reg = NULL; | ||
| 2164 | 2166 | ||
| 2165 | /* | 2167 | /* |
| 2166 | * From spc4r17, section 5.7.11.3 Unregistering | 2168 | * From spc4r17, section 5.7.11.3 Unregistering |
| @@ -2174,8 +2176,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
| 2174 | * RESERVATIONS RELEASED. | 2176 | * RESERVATIONS RELEASED. |
| 2175 | */ | 2177 | */ |
| 2176 | if (pr_holder && | 2178 | if (pr_holder && |
| 2177 | (pr_reg->pr_res_type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY || | 2179 | (type == PR_TYPE_WRITE_EXCLUSIVE_REGONLY || |
| 2178 | pr_reg->pr_res_type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) { | 2180 | type == PR_TYPE_EXCLUSIVE_ACCESS_REGONLY)) { |
| 2179 | list_for_each_entry(pr_reg_p, | 2181 | list_for_each_entry(pr_reg_p, |
| 2180 | &pr_tmpl->registration_list, | 2182 | &pr_tmpl->registration_list, |
| 2181 | pr_reg_list) { | 2183 | pr_reg_list) { |
| @@ -2194,7 +2196,8 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, | |||
| 2194 | ret = core_scsi3_update_and_write_aptpl(dev, aptpl); | 2196 | ret = core_scsi3_update_and_write_aptpl(dev, aptpl); |
| 2195 | 2197 | ||
| 2196 | out: | 2198 | out: |
| 2197 | core_scsi3_put_pr_reg(pr_reg); | 2199 | if (pr_reg) |
| 2200 | core_scsi3_put_pr_reg(pr_reg); | ||
| 2198 | return ret; | 2201 | return ret; |
| 2199 | } | 2202 | } |
| 2200 | 2203 | ||
