On 09/29/2016 07:01 PM, Bart Van Assche wrote: > 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? > Ah, now I see what you mean. However, your patch is still incorrect; when doing so we'll end up with a duplicate reference if the call to queue_delayed_work() succeeds. I'll be sending an updated patch. Cheers, Hannes -- Dr. Hannes Reinecke zSeries & Storage hare@xxxxxxx +49 911 74053 688 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: J. Hawn, J. Guild, F. Imendörffer, HRB 16746 (AG Nürnberg) -- 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