re: target: Add support for COMPARE_AND_WRITE emulation

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

 



Hello Nicholas Bellinger,

The patch 2450acf26519: "target: Add support for COMPARE_AND_WRITE
emulation" from Aug 19, 2013, leads to the following static checker
warning: "drivers/target/target_core_sbc.c:508 sbc_compare_and_write()
	 warn: 'sem:&dev->caw_sem' is sometimes locked here and
	sometimes unlocked."

drivers/target/target_core_sbc.c
   502          /*
   503           * Submit the READ first for COMPARE_AND_WRITE to perform the
   504           * comparision using SGLs at cmd->t_bidi_data_sg..
   505           */
   506          rc = down_interruptible(&dev->caw_sem);
   507          if ((rc != 0) || signal_pending(current))
   508                  return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

When we return here, we don't know if we are holding the lock or not.
I believe that we release this lock in compare_and_write_callback() so
this is actually a double unlock bug and not a deadlock.

   509  
   510          ret = cmd->execute_rw(cmd, cmd->t_bidi_data_sg, cmd->t_bidi_data_nents,
   511                                DMA_FROM_DEVICE);
   512          if (ret) {
   513                  up(&dev->caw_sem);
                        ^^^^^^^^^^^^^^^^^^
This may be a double unlock bug as well.

   514                  return ret;
   515          }
   516          /*
   517           * Unlock of dev->caw_sem to occur in compare_and_write_callback()
   518           * upon MISCOMPARE, or in compare_and_write_done() upon completion
   519           * of WRITE instance user-data.
   520           */
   521          return TCM_NO_SENSE;


regards,
dan carpenter

--
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