Re: [target:for-next 9/33] drivers/target/target_core_pr.c:2069:57: sparse: incorrect type in return expression (different base types)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2013-06-21 at 08:41 +0800, kbuild test robot wrote:
> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/nab/target-pending.git for-next
> head:   28027b5d78ddb784df5a919d526e4a111652632f
> commit: 459f213ba162bd13e113d6f92a8fa6c780fd67ed [9/33] target: Allocate aptpl_buf inside update_and_write_aptpl()
> 
> 
> sparse warnings: (new ones prefixed by >>)
> 
> >> 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
> 
> vim +2069 drivers/target/target_core_pr.c
> 
>   2063				ret = core_scsi3_decode_spec_i_port(cmd, se_tpg,
>   2064						isid_ptr, sa_res_key, all_tg_pt, aptpl);
>   2065				if (ret != 0)
>   2066					return ret;
>   2067			}
>   2068	
> > 2069			return core_scsi3_update_and_write_aptpl(dev, aptpl);
>   2070		}

Hi Fengguang,

I've applied the following patch into for-next to address this breakage.

Thanks!

--nab

diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 05c3f42..bd78faf 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -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;
 
-               buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL);
-               if (!buf)
-                       return -ENOMEM;
+               if (rc)
+                       return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
 
-               ret = core_scsi3_update_aptpl_buf(dev, buf, PR_APTPL_BUF_LEN);
-               if (ret < 0) {
-                       kfree(buf);
-                       return ret;
-               }
+               return 0;
+       }
 
-               ret = __core_scsi3_write_aptpl_to_file(dev, buf);
-               if (ret != 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");
-               }
+       buf = kzalloc(PR_APTPL_BUF_LEN, GFP_KERNEL);
+       if (!buf)
+               return TCM_OUT_OF_RESOURCES;
+
+       rc = core_scsi3_update_aptpl_buf(dev, buf, PR_APTPL_BUF_LEN);
+       if (rc < 0) {
                kfree(buf);
+               return TCM_OUT_OF_RESOURCES;
        }
 
-       return ret;
+       rc = __core_scsi3_write_aptpl_to_file(dev, buf);
+       if (rc != 0) {
+               pr_err("SPC-3 PR: Could not update APTPL\n");
+               kfree(buf);
+               return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
+       }
+       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

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux