target: Fix free-after-use regression in PR unregister
authorNicholas Bellinger <nab@linux-iscsi.org>
Thu, 30 Jan 2014 21:08:49 +0000 (13:08 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 12 Feb 2014 23:11:01 +0000 (15:11 -0800)
commitfc09149df6e20cfbb0bb86f10899607c321a31eb
treed8b6190b82010100caec7643e065d2dc233bc013
parentb28a960c42fcd9cfc987441fa6d1c1a471f0f9ed
target: Fix free-after-use regression in PR unregister

This patch addresses a >= v3.11 free-after-use regression
in core_scsi3_emulate_pro_register() that was introduced
in the following commit:

commit bc118fe4c4a8cfa453491ba77c0a146a6d0e73e0
Author: Andy Grover <agrover@redhat.com>
Date:   Thu May 16 10:41:04 2013 -0700

    target: Further refactoring of core_scsi3_emulate_pro_register()

To avoid the free-after-use, save an type value before hand, and
only call core_scsi3_put_pr_reg() with a valid *pr_reg.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Andy Grover <agrover@redhat.com>
Cc: <stable@vger.kernel.org> #3.11+
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_pr.c