diff mbox

[1/2] xen/scsiback: correct frontend counting

Message ID 1454678503-7999-1-git-send-email-jgross@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jürgen Groß Feb. 5, 2016, 1:21 p.m. UTC
When adding a new frontend to xen-scsiback don't decrement the number
of active frontends in case of no error. Not doing so results in a
failure when trying to remove the xen-pvscsi nexus even if no domain
is using it.

Signed-off-by: Juergen Gross <jgross@suse.com>
Cc: stable@vger.kernel.org
---
 drivers/xen/xen-scsiback.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Boris Ostrovsky Feb. 5, 2016, 3:42 p.m. UTC | #1
On 02/05/2016 08:21 AM, Juergen Gross wrote:
> When adding a new frontend to xen-scsiback don't decrement the number
> of active frontends in case of no error. Not doing so results in a

I think you meant "Doing so".

Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>


> failure when trying to remove the xen-pvscsi nexus even if no domain
> is using it.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> Cc: stable@vger.kernel.org
> ---
>   drivers/xen/xen-scsiback.c | 10 +++++-----
>   1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
> index ad4eb10..51387d7 100644
> --- a/drivers/xen/xen-scsiback.c
> +++ b/drivers/xen/xen-scsiback.c
> @@ -939,12 +939,12 @@ out:
>   	spin_unlock_irqrestore(&info->v2p_lock, flags);
>   
>   out_free:
> -	mutex_lock(&tpg->tv_tpg_mutex);
> -	tpg->tv_tpg_fe_count--;
> -	mutex_unlock(&tpg->tv_tpg_mutex);
> -
> -	if (err)
> +	if (err) {
> +		mutex_lock(&tpg->tv_tpg_mutex);
> +		tpg->tv_tpg_fe_count--;
> +		mutex_unlock(&tpg->tv_tpg_mutex);
>   		kfree(new);
> +	}
>   
>   	return err;
>   }
Jürgen Groß Feb. 5, 2016, 3:44 p.m. UTC | #2
On 05/02/16 16:42, Boris Ostrovsky wrote:
> 
> 
> On 02/05/2016 08:21 AM, Juergen Gross wrote:
>> When adding a new frontend to xen-scsiback don't decrement the number
>> of active frontends in case of no error. Not doing so results in a
> 
> I think you meant "Doing so".

I think so, too.

> 
> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>

Thanks, Juergen

> 
> 
>> failure when trying to remove the xen-pvscsi nexus even if no domain
>> is using it.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>> Cc: stable@vger.kernel.org
>> ---
>>   drivers/xen/xen-scsiback.c | 10 +++++-----
>>   1 file changed, 5 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
>> index ad4eb10..51387d7 100644
>> --- a/drivers/xen/xen-scsiback.c
>> +++ b/drivers/xen/xen-scsiback.c
>> @@ -939,12 +939,12 @@ out:
>>       spin_unlock_irqrestore(&info->v2p_lock, flags);
>>     out_free:
>> -    mutex_lock(&tpg->tv_tpg_mutex);
>> -    tpg->tv_tpg_fe_count--;
>> -    mutex_unlock(&tpg->tv_tpg_mutex);
>> -
>> -    if (err)
>> +    if (err) {
>> +        mutex_lock(&tpg->tv_tpg_mutex);
>> +        tpg->tv_tpg_fe_count--;
>> +        mutex_unlock(&tpg->tv_tpg_mutex);
>>           kfree(new);
>> +    }
>>         return err;
>>   }
> 
>
diff mbox

Patch

diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index ad4eb10..51387d7 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -939,12 +939,12 @@  out:
 	spin_unlock_irqrestore(&info->v2p_lock, flags);
 
 out_free:
-	mutex_lock(&tpg->tv_tpg_mutex);
-	tpg->tv_tpg_fe_count--;
-	mutex_unlock(&tpg->tv_tpg_mutex);
-
-	if (err)
+	if (err) {
+		mutex_lock(&tpg->tv_tpg_mutex);
+		tpg->tv_tpg_fe_count--;
+		mutex_unlock(&tpg->tv_tpg_mutex);
 		kfree(new);
+	}
 
 	return err;
 }