All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi_dh_alua: Fix a reference counting bug
@ 2016-09-28 23:45 Bart Van Assche
  2016-09-28 23:58 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Bart Van Assche @ 2016-09-28 23:45 UTC (permalink / raw)
  To: James Bottomley, Martin K. Petersen; +Cc: Hannes Reinecke, linux-scsi

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@sandisk.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: <stable@vger.kernel.org>
---
 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;
 		}
 	}
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code
  2016-09-28 23:45 [PATCH] scsi_dh_alua: Fix a reference counting bug Bart Van Assche
@ 2016-09-28 23:58 ` Bart Van Assche
  2016-09-29  5:53   ` Hannes Reinecke
  2016-09-28 23:59 ` [PATCH v2 3/7] [RFC] nvme: " Bart Van Assche
  2016-09-29  5:46 ` [PATCH] scsi_dh_alua: Fix a reference counting bug Hannes Reinecke
  2 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2016-09-28 23:58 UTC (permalink / raw)
  To: James Bottomley, Martin K. Petersen; +Cc: Hannes Reinecke, linux-scsi

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Mike Snitzer <snitzer@redhat.com>
---
 drivers/md/dm-rq.c | 18 ++----------------
 1 file changed, 2 insertions(+), 16 deletions(-)

diff --git a/drivers/md/dm-rq.c b/drivers/md/dm-rq.c
index 182b679..f2c271a 100644
--- a/drivers/md/dm-rq.c
+++ b/drivers/md/dm-rq.c
@@ -75,12 +75,6 @@ static void dm_old_start_queue(struct request_queue *q)
 
 static void dm_mq_start_queue(struct request_queue *q)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(q->queue_lock, flags);
-	queue_flag_clear(QUEUE_FLAG_STOPPED, q);
-	spin_unlock_irqrestore(q->queue_lock, flags);
-
 	blk_mq_start_stopped_hw_queues(q, true);
 	blk_mq_kick_requeue_list(q);
 }
@@ -105,16 +99,8 @@ static void dm_old_stop_queue(struct request_queue *q)
 
 static void dm_mq_stop_queue(struct request_queue *q)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(q->queue_lock, flags);
-	if (blk_queue_stopped(q)) {
-		spin_unlock_irqrestore(q->queue_lock, flags);
+	if (blk_mq_queue_stopped(q))
 		return;
-	}
-
-	queue_flag_set(QUEUE_FLAG_STOPPED, q);
-	spin_unlock_irqrestore(q->queue_lock, flags);
 
 	/* Avoid that requeuing could restart the queue. */
 	blk_mq_cancel_requeue_work(q);
@@ -341,7 +327,7 @@ static void __dm_mq_kick_requeue_list(struct request_queue *q, unsigned long mse
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
-	if (!blk_queue_stopped(q))
+	if (!blk_mq_queue_stopped(q))
 		blk_mq_delay_kick_requeue_list(q, msecs);
 	spin_unlock_irqrestore(q->queue_lock, flags);
 }
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v2 3/7] [RFC] nvme: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code
  2016-09-28 23:45 [PATCH] scsi_dh_alua: Fix a reference counting bug Bart Van Assche
  2016-09-28 23:58 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
@ 2016-09-28 23:59 ` Bart Van Assche
  2016-09-29  5:46 ` [PATCH] scsi_dh_alua: Fix a reference counting bug Hannes Reinecke
  2 siblings, 0 replies; 10+ messages in thread
From: Bart Van Assche @ 2016-09-28 23:59 UTC (permalink / raw)
  To: James Bottomley, Martin K. Petersen; +Cc: Hannes Reinecke, linux-scsi

Make nvme_requeue_req() check BLK_MQ_S_STOPPED instead of
QUEUE_FLAG_STOPPED. Remove the QUEUE_FLAG_STOPPED manipulations
that became superfluous because of this change. This patch fixes
a race condition: using queue_flag_clear_unlocked() is not safe
if any other function that manipulates the queue flags can be
called concurrently, e.g. blk_cleanup_queue(). Untested.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Keith Busch <keith.busch@intel.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
---
 drivers/nvme/host/core.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4669c05..d791fba 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -205,7 +205,7 @@ void nvme_requeue_req(struct request *req)
 
 	blk_mq_requeue_request(req);
 	spin_lock_irqsave(req->q->queue_lock, flags);
-	if (!blk_queue_stopped(req->q))
+	if (!blk_mq_queue_stopped(req->q))
 		blk_mq_kick_requeue_list(req->q);
 	spin_unlock_irqrestore(req->q->queue_lock, flags);
 }
@@ -2080,10 +2080,6 @@ void nvme_stop_queues(struct nvme_ctrl *ctrl)
 
 	mutex_lock(&ctrl->namespaces_mutex);
 	list_for_each_entry(ns, &ctrl->namespaces, list) {
-		spin_lock_irq(ns->queue->queue_lock);
-		queue_flag_set(QUEUE_FLAG_STOPPED, ns->queue);
-		spin_unlock_irq(ns->queue->queue_lock);
-
 		blk_mq_cancel_requeue_work(ns->queue);
 		blk_mq_stop_hw_queues(ns->queue);
 	}
@@ -2097,7 +2093,6 @@ void nvme_start_queues(struct nvme_ctrl *ctrl)
 
 	mutex_lock(&ctrl->namespaces_mutex);
 	list_for_each_entry(ns, &ctrl->namespaces, list) {
-		queue_flag_clear_unlocked(QUEUE_FLAG_STOPPED, ns->queue);
 		blk_mq_start_stopped_hw_queues(ns->queue, true);
 		blk_mq_kick_requeue_list(ns->queue);
 	}
-- 
2.10.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] scsi_dh_alua: Fix a reference counting bug
  2016-09-28 23:45 [PATCH] scsi_dh_alua: Fix a reference counting bug Bart Van Assche
  2016-09-28 23:58 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
  2016-09-28 23:59 ` [PATCH v2 3/7] [RFC] nvme: " Bart Van Assche
@ 2016-09-29  5:46 ` Hannes Reinecke
  2016-09-29 17:01   ` Bart Van Assche
  2 siblings, 1 reply; 10+ messages in thread
From: Hannes Reinecke @ 2016-09-29  5:46 UTC (permalink / raw)
  To: Bart Van Assche, James Bottomley, Martin K. Petersen; +Cc: linux-scsi

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@sandisk.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: <stable@vger.kernel.org>
> ---
>  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.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code
  2016-09-28 23:58 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
@ 2016-09-29  5:53   ` Hannes Reinecke
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2016-09-29  5:53 UTC (permalink / raw)
  To: Bart Van Assche, James Bottomley, Martin K. Petersen; +Cc: linux-scsi

On 09/29/2016 01:58 AM, Bart Van Assche wrote:
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Mike Snitzer <snitzer@redhat.com>
> ---
>  drivers/md/dm-rq.c | 18 ++----------------
>  1 file changed, 2 insertions(+), 16 deletions(-)
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] scsi_dh_alua: Fix a reference counting bug
  2016-09-29  5:46 ` [PATCH] scsi_dh_alua: Fix a reference counting bug Hannes Reinecke
@ 2016-09-29 17:01   ` Bart Van Assche
  2016-10-04  8:08     ` Hannes Reinecke
  0 siblings, 1 reply; 10+ messages in thread
From: Bart Van Assche @ 2016-09-29 17:01 UTC (permalink / raw)
  To: Hannes Reinecke, James Bottomley, Martin K. Petersen; +Cc: linux-scsi

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@sandisk.com>
>> Cc: Hannes Reinecke <hare@suse.com>
>> Cc: <stable@vger.kernel.org>
>> ---
>>  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.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] scsi_dh_alua: Fix a reference counting bug
  2016-09-29 17:01   ` Bart Van Assche
@ 2016-10-04  8:08     ` Hannes Reinecke
  0 siblings, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2016-10-04  8:08 UTC (permalink / raw)
  To: Bart Van Assche, James Bottomley, Martin K. Petersen; +Cc: linux-scsi

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@sandisk.com>
>>> Cc: Hannes Reinecke <hare@suse.com>
>>> Cc: <stable@vger.kernel.org>
>>> ---
>>>  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@suse.de			      +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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] scsi_dh_alua: Fix a reference counting bug
  2016-11-01 14:19 Bart Van Assche
  2016-11-01 16:59 ` Hannes Reinecke
@ 2016-11-01 17:32 ` Martin K. Petersen
  1 sibling, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2016-11-01 17:32 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: Martin K. Petersen, James Bottomley, Hannes Reinecke,
	tang.junhui, linux-scsi

>>>>> "Bart" == Bart Van Assche <bart.vanassche@sandisk.com> writes:

Bart> The code at the end of alua_rtpg_work() is as follows:
Bart> 	scsi_device_put(sdev);
Bart> 	kref_put(&pg->kref, release_port_group);

Bart> In other words, alua_rtpg_queue() must hold an sdev reference and
Bart> a pg reference before queueing rtpg work. If no rtpg work is
Bart> queued no additional references should be held when
Bart> alua_rtpg_queue() returns. If no rtpg work is queued, ensure that
Bart> alua_rtpg_queue() only gives up the sdev reference if that
Bart> reference was obtained by the same alua_rtpg_queue() call.

Applied to 4.9/scsi-fixes.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] scsi_dh_alua: Fix a reference counting bug
  2016-11-01 14:19 Bart Van Assche
@ 2016-11-01 16:59 ` Hannes Reinecke
  2016-11-01 17:32 ` Martin K. Petersen
  1 sibling, 0 replies; 10+ messages in thread
From: Hannes Reinecke @ 2016-11-01 16:59 UTC (permalink / raw)
  To: Bart Van Assche, Martin K. Petersen, James Bottomley
  Cc: tang.junhui, linux-scsi

On 11/01/2016 03:19 PM, 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);
>
> In other words, alua_rtpg_queue() must hold an sdev reference and
> a pg reference before queueing rtpg work. If no rtpg work is queued
> no additional references should be held when alua_rtpg_queue()
> returns. If no rtpg work is queued, ensure that alua_rtpg_queue()
> only gives up the sdev reference if that reference was obtained by
> the same alua_rtpg_queue() call.
>
> Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
> Cc: Hannes Reinecke <hare@suse.com>
> Cc: Tang Junhui <tang.junhui@zte.com.cn>
> Cc: <stable@vger.kernel.org>
> ---
>  drivers/scsi/device_handler/scsi_dh_alua.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
> index f375167..7bb2068 100644
> --- a/drivers/scsi/device_handler/scsi_dh_alua.c
> +++ b/drivers/scsi/device_handler/scsi_dh_alua.c
> @@ -891,6 +891,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);
> +			sdev = NULL;
>  			start_queue = 1;
>  		}
>  	}
> @@ -902,7 +903,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
>  	if (start_queue &&
>  	    !queue_delayed_work(alua_wq, &pg->rtpg_work,
>  				msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
> -		scsi_device_put(sdev);
> +		if (sdev)
> +			scsi_device_put(sdev);
>  		kref_put(&pg->kref, release_port_group);
>  	}
>  }
>
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +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)

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] scsi_dh_alua: Fix a reference counting bug
@ 2016-11-01 14:19 Bart Van Assche
  2016-11-01 16:59 ` Hannes Reinecke
  2016-11-01 17:32 ` Martin K. Petersen
  0 siblings, 2 replies; 10+ messages in thread
From: Bart Van Assche @ 2016-11-01 14:19 UTC (permalink / raw)
  To: Martin K. Petersen, James Bottomley
  Cc: Hannes Reinecke, tang.junhui, linux-scsi

The code at the end of alua_rtpg_work() is as follows:

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

In other words, alua_rtpg_queue() must hold an sdev reference and
a pg reference before queueing rtpg work. If no rtpg work is queued
no additional references should be held when alua_rtpg_queue()
returns. If no rtpg work is queued, ensure that alua_rtpg_queue()
only gives up the sdev reference if that reference was obtained by
the same alua_rtpg_queue() call.

Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Tang Junhui <tang.junhui@zte.com.cn>
Cc: <stable@vger.kernel.org>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index f375167..7bb2068 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -891,6 +891,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);
+			sdev = NULL;
 			start_queue = 1;
 		}
 	}
@@ -902,7 +903,8 @@ static void alua_rtpg_queue(struct alua_port_group *pg,
 	if (start_queue &&
 	    !queue_delayed_work(alua_wq, &pg->rtpg_work,
 				msecs_to_jiffies(ALUA_RTPG_DELAY_MSECS))) {
-		scsi_device_put(sdev);
+		if (sdev)
+			scsi_device_put(sdev);
 		kref_put(&pg->kref, release_port_group);
 	}
 }
-- 
2.10.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-11-01 17:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-28 23:45 [PATCH] scsi_dh_alua: Fix a reference counting bug Bart Van Assche
2016-09-28 23:58 ` [PATCH v2 2/7] dm: Use BLK_MQ_S_STOPPED instead of QUEUE_FLAG_STOPPED in blk-mq code Bart Van Assche
2016-09-29  5:53   ` Hannes Reinecke
2016-09-28 23:59 ` [PATCH v2 3/7] [RFC] nvme: " Bart Van Assche
2016-09-29  5:46 ` [PATCH] scsi_dh_alua: Fix a reference counting bug Hannes Reinecke
2016-09-29 17:01   ` Bart Van Assche
2016-10-04  8:08     ` Hannes Reinecke
2016-11-01 14:19 Bart Van Assche
2016-11-01 16:59 ` Hannes Reinecke
2016-11-01 17:32 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.