scsi: scsi_dh_alua: Fix a reference counting bug
authorBart Van Assche <bart.vanassche@sandisk.com>
Tue, 1 Nov 2016 14:19:57 +0000 (08:19 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 1 Nov 2016 17:32:24 +0000 (13:32 -0400)
commitdf3d422cbac685da882e4c239dfda07de33d431b
tree5d61ed8c7e551eb980a4c1772964bdce25d8c1d8
parentaac173e9618faadf8f92af6cc05e64f7acc64d79
scsi: scsi_dh_alua: Fix a reference counting bug

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>
Reported-by: Tang Junhui <tang.junhui@zte.com.cn>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Tang Junhui <tang.junhui@zte.com.cn>
Cc: <stable@vger.kernel.org>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/device_handler/scsi_dh_alua.c