Re: [PATCH] Separate target visibility from reaped state information

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

 



On 02/02/2016 03:46 AM, James Bottomley wrote:
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 4f18a85..00bc721 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -1272,16 +1272,18 @@ static void __scsi_remove_target(struct scsi_target *starget)
  void scsi_remove_target(struct device *dev)
  {
      struct Scsi_Host *shost = dev_to_shost(dev->parent);
-     struct scsi_target *starget;
+     struct scsi_target *starget, *last_target = NULL;
      unsigned long flags;

  restart:
      spin_lock_irqsave(shost->host_lock, flags);
      list_for_each_entry(starget, &shost->__targets, siblings) {
-             if (starget->state == STARGET_DEL)
+             if (starget->state == STARGET_DEL ||
+                 starget == last_target)
                      continue;
              if (starget->dev.parent == dev || &starget->dev == dev) {
                      kref_get(&starget->reap_ref);
+                     last_target = starget;
                      spin_unlock_irqrestore(shost->host_lock, flags);
                      __scsi_remove_target(starget);
                      scsi_target_reap(starget);

Hello James,

Do you think it is a robust approach to store the pointer to the last
removed target in the last_target variable ? What if e.g.
scsi_target_reap() frees the memory the last_target pointer points at
and another thread reallocates a scsi_target data structure ? Can that
last data structure have the same address as the contents of the
last_target variable ?

Thanks,

Bart.
PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux