Commit 8a391857 authored by Nicholas Bellinger's avatar Nicholas Bellinger

target: Make core_scsi3_update_and_write_aptpl return sense_reason_t

Fix up sense_reason_t breakage in core_scsi3_update_and_write_aptpl()
from recent conversion to use local scope memory allocation.

Reported as sparse warnings: (new ones prefixed by >>) by Fengguang:

>> drivers/target/target_core_pr.c:2069:57: sparse: incorrect type in
>> return expression (different base types)
   drivers/target/target_core_pr.c:2069:57:    expected restricted sense_reason_t
   drivers/target/target_core_pr.c:2069:57:    got int
>> drivers/target/target_core_pr.c:2179:21: sparse: incorrect type in
>> assignment (different base types)
   drivers/target/target_core_pr.c:2179:21:    expected restricted sense_reason_t [assigned] [usertype] ret
   drivers/target/target_core_pr.c:2179:21:    got int
>> drivers/target/target_core_pr.c:2197:13: sparse: incorrect type in
>> assignment (different base types)
   drivers/target/target_core_pr.c:2197:13:    expected restricted sense_reason_t [assigned] [usertype] ret
   drivers/target/target_core_pr.c:2197:13:    got int
   drivers/target/target_core_pr.c:1245:28: sparse: context imbalance in '__core_scsi3_free_registration' - unexpected unlock
Reported-by: default avatarkbuild test robot <fengguang.wu@intel.com>
Cc: Andy Grover <agrover@redhat.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent c3e51442
......@@ -1956,41 +1956,44 @@ static int __core_scsi3_write_aptpl_to_file(
* Clear the APTPL metadata if APTPL has been disabled, otherwise
* write out the updated metadata to struct file for this SCSI device.
*/
static int core_scsi3_update_and_write_aptpl(struct se_device *dev, bool aptpl)
static sense_reason_t core_scsi3_update_and_write_aptpl(struct se_device *dev, bool aptpl)
{
int ret = 0;
unsigned char *buf;
int rc;
if (!aptpl) {
char *null_buf = "No Registrations or Reservations\n";
ret = __core_scsi3_write_aptpl_to_file(dev, null_buf);
rc = __core_scsi3_write_aptpl_to_file(dev, null_buf);
dev->t10_pr.pr_aptpl_active = 0;
pr_debug("SPC-3 PR: Set APTPL Bit Deactivated\n");
} else {
int ret;
unsigned char *buf;
if (rc)
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
return 0;
}
buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL);
if (!buf)
return -ENOMEM;
return TCM_OUT_OF_RESOURCES;
ret = core_scsi3_update_aptpl_buf(dev, buf, PR_APTPL_BUF_LEN);
if (ret < 0) {
rc = core_scsi3_update_aptpl_buf(dev, buf, PR_APTPL_BUF_LEN);
if (rc < 0) {
kfree(buf);
return ret;
return TCM_OUT_OF_RESOURCES;
}
ret = __core_scsi3_write_aptpl_to_file(dev, buf);
if (ret != 0) {
rc = __core_scsi3_write_aptpl_to_file(dev, buf);
if (rc != 0) {
pr_err("SPC-3 PR: Could not update APTPL\n");
} else {
dev->t10_pr.pr_aptpl_active = 1;
pr_debug("SPC-3 PR: Set APTPL Bit Activated\n");
}
kfree(buf);
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
}
return ret;
dev->t10_pr.pr_aptpl_active = 1;
kfree(buf);
pr_debug("SPC-3 PR: Set APTPL Bit Activated\n");
return 0;
}
static sense_reason_t
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment