Re: [PATCH] scsi_dh_alua: Fix a reference counting bug

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

 



On 09/28/2016 10:46 PM, Hannes Reinecke wrote:
On 09/29/2016 01:45 AM, Bart Van Assche wrote:
The code at the end of alua_rtpg_work() is as follows:

	scsi_device_put(sdev);
	kref_put(&pg->kref, release_port_group);

Make sure that all code that queues the work item associated
with alua_rtpg_work() holds both references.

Signed-off-by: Bart Van Assche <bart.vanassche@xxxxxxxxxxx>
Cc: Hannes Reinecke <hare@xxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 752b5c9..f7099e2 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -889,6 +889,7 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
 		/* Do not queue if the worker is already running */
 		if (!(pg->flags & ALUA_PG_RUNNING)) {
 			kref_get(&pg->kref);
+			scsi_device_get(sdev);
 			start_queue = 1;
 		}
 	}

Nack.

The scsi device reference tracks ->rtpg_sdev, not the queue item.
So we only need to take the scsi device reference if we're assigning a
new value to ->rtpg_sdev, which we are not.

Hello Hannes,

If queue_delayed_work() returns 0 that means that a call to alua_rtpg_work() has already been scheduled. alua_rtpg_work() will drop the reference on pg->rtpg_sdev. Are you sure that alua_rtpg_queue() should call scsi_device_put(sdev) in that case?

Thanks,

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