diff mbox

arm/arm64: KVM: fix missing unlock on error in kvm_vgic_create()

Message ID 1425037305-23292-1-git-send-email-weiyj_lk@163.com (mailing list archive)
State New, archived
Headers show

Commit Message

weiyj_lk@163.com Feb. 27, 2015, 11:41 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Add the missing unlock before return from function kvm_vgic_create()
in the error handling case.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 virt/kvm/arm/vgic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andre Przywara Feb. 27, 2015, 12:07 p.m. UTC | #1
Hi Wei,

On 27/02/15 11:41, weiyj_lk@163.com wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> Add the missing unlock before return from function kvm_vgic_create()
> in the error handling case.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>  virt/kvm/arm/vgic.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
> index 0cc6ab6..4b2c2e7 100644
> --- a/virt/kvm/arm/vgic.c
> +++ b/virt/kvm/arm/vgic.c
> @@ -1583,8 +1583,10 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
>  	 * emulation. So check this here again. KVM_CREATE_DEVICE does
>  	 * the proper checks already.
>  	 */
> -	if (type == KVM_DEV_TYPE_ARM_VGIC_V2 && !vgic->can_emulate_gicv2)
> -		return -ENODEV;
> +	if (type == KVM_DEV_TYPE_ARM_VGIC_V2 && !vgic->can_emulate_gicv2) {
> +		ret = -ENODEV;
> +		goto out;
> +	}

Ah, good catch. Embarrassing that that could slip through ...


Acked-by: Andre Przywara <andre.przywara@arm.com>


Out of curiosity: did you see it hang or was this just by looking at the
code? I thought that I tested this case ...

Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoffer Dall March 2, 2015, 5:29 p.m. UTC | #2
On Fri, Feb 27, 2015 at 07:41:45PM +0800, weiyj_lk@163.com wrote:
> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> Add the missing unlock before return from function kvm_vgic_create()
> in the error handling case.
> 
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Thanks, applied.
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andre Przywara March 13, 2015, 10:24 a.m. UTC | #3
Hej Christoffer,

On 02/03/15 17:29, Christoffer Dall wrote:
> On Fri, Feb 27, 2015 at 07:41:45PM +0800, weiyj_lk@163.com wrote:
>> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>>
>> Add the missing unlock before return from function kvm_vgic_create()
>> in the error handling case.
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> 
> Thanks, applied.

Have I missed this or is this patch nor appearing in any of your branches?

Cheers,
Andre.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Christoffer Dall March 13, 2015, 10:41 a.m. UTC | #4
On Fri, Mar 13, 2015 at 10:24:21AM +0000, Andre Przywara wrote:
> Hej Christoffer,
> 
> On 02/03/15 17:29, Christoffer Dall wrote:
> > On Fri, Feb 27, 2015 at 07:41:45PM +0800, weiyj_lk@163.com wrote:
> >> From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> >>
> >> Add the missing unlock before return from function kvm_vgic_create()
> >> in the error handling case.
> >>
> >> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> > 
> > Thanks, applied.
> 
> Have I missed this or is this patch nor appearing in any of your branches?
> 
It was on my laptop branch because I applied while being on a plane.

I've updated the kvmarm/master branch with this fix.

Thanks for reminding me.
-Christoffer
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 0cc6ab6..4b2c2e7 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1583,8 +1583,10 @@  int kvm_vgic_create(struct kvm *kvm, u32 type)
 	 * emulation. So check this here again. KVM_CREATE_DEVICE does
 	 * the proper checks already.
 	 */
-	if (type == KVM_DEV_TYPE_ARM_VGIC_V2 && !vgic->can_emulate_gicv2)
-		return -ENODEV;
+	if (type == KVM_DEV_TYPE_ARM_VGIC_V2 && !vgic->can_emulate_gicv2) {
+		ret = -ENODEV;
+		goto out;
+	}
 
 	/*
 	 * Any time a vcpu is run, vcpu_load is called which tries to grab the