diff mbox

[-next] vfio/type1: fix error return code in vfio_iommu_type1_attach_group()

Message ID 20170209160158.24497-1-weiyj.lk@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Wei Yongjun Feb. 9, 2017, 4:01 p.m. UTC
From: Wei Yongjun <weiyongjun1@huawei.com>

Fix to return a negative error code from the error handling
case instead of 0, as done elsewhere in this function.

Fixes: 5d704992189f ("vfio/type1: Allow transparent MSI IOVA allocation")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/vfio/vfio_iommu_type1.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Auger Eric Feb. 9, 2017, 5:03 p.m. UTC | #1
Hi Wei,

On 09/02/2017 17:01, Wei Yongjun wrote:
> From: Wei Yongjun <weiyongjun1@huawei.com>
> 
> Fix to return a negative error code from the error handling
> case instead of 0, as done elsewhere in this function.
> 
> Fixes: 5d704992189f ("vfio/type1: Allow transparent MSI IOVA allocation")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Reviewed-by: Eric Auger <eric.auger@redhat.com>

Thanks for spotting this.

Eric


> ---
>  drivers/vfio/vfio_iommu_type1.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 0f353f5..bd6f293 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -1332,8 +1332,11 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
>  	if (ret)
>  		goto out_detach;
>  
> -	if (resv_msi && iommu_get_msi_cookie(domain->domain, resv_msi_base))
> -		goto out_detach;
> +	if (resv_msi) {
> +		ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
> +		if (ret)
> +			goto out_detach;
> +	}
>  
>  	list_add(&domain->next, &iommu->domain_list);
>
Alex Williamson Feb. 9, 2017, 6:23 p.m. UTC | #2
On Thu, 9 Feb 2017 18:03:47 +0100
Auger Eric <eric.auger@redhat.com> wrote:

> Hi Wei,
> 
> On 09/02/2017 17:01, Wei Yongjun wrote:
> > From: Wei Yongjun <weiyongjun1@huawei.com>
> > 
> > Fix to return a negative error code from the error handling
> > case instead of 0, as done elsewhere in this function.
> > 
> > Fixes: 5d704992189f ("vfio/type1: Allow transparent MSI IOVA allocation")
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>  
> 
> Reviewed-by: Eric Auger <eric.auger@redhat.com>

Acked-by: Alex Williamson <alex.williamson@redhat.com>

Joerg/Will,

The original commit comes in through iommu/next (arm/core), please feel
free to also include this fix.  Thanks,

Alex

> > ---
> >  drivers/vfio/vfio_iommu_type1.c | 7 +++++--
> >  1 file changed, 5 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> > index 0f353f5..bd6f293 100644
> > --- a/drivers/vfio/vfio_iommu_type1.c
> > +++ b/drivers/vfio/vfio_iommu_type1.c
> > @@ -1332,8 +1332,11 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
> >  	if (ret)
> >  		goto out_detach;
> >  
> > -	if (resv_msi && iommu_get_msi_cookie(domain->domain, resv_msi_base))
> > -		goto out_detach;
> > +	if (resv_msi) {
> > +		ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
> > +		if (ret)
> > +			goto out_detach;
> > +	}
> >  
> >  	list_add(&domain->next, &iommu->domain_list);
> >
Will Deacon Feb. 10, 2017, 11:56 a.m. UTC | #3
On Thu, Feb 09, 2017 at 11:23:11AM -0700, Alex Williamson wrote:
> On Thu, 9 Feb 2017 18:03:47 +0100
> Auger Eric <eric.auger@redhat.com> wrote:
> > On 09/02/2017 17:01, Wei Yongjun wrote:
> > > From: Wei Yongjun <weiyongjun1@huawei.com>
> > > 
> > > Fix to return a negative error code from the error handling
> > > case instead of 0, as done elsewhere in this function.
> > > 
> > > Fixes: 5d704992189f ("vfio/type1: Allow transparent MSI IOVA allocation")
> > > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>  
> > 
> > Reviewed-by: Eric Auger <eric.auger@redhat.com>
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
> 
> Joerg/Will,
> 
> The original commit comes in through iommu/next (arm/core), please feel
> free to also include this fix.  Thanks,

Patch looks fine to me. Joerg, can you pick this up please?

Will
Joerg Roedel Feb. 10, 2017, 12:51 p.m. UTC | #4
On Fri, Feb 10, 2017 at 11:56:47AM +0000, Will Deacon wrote:
> Patch looks fine to me. Joerg, can you pick this up please?

Picked up, thanks.
diff mbox

Patch

diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 0f353f5..bd6f293 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -1332,8 +1332,11 @@  static int vfio_iommu_type1_attach_group(void *iommu_data,
 	if (ret)
 		goto out_detach;
 
-	if (resv_msi && iommu_get_msi_cookie(domain->domain, resv_msi_base))
-		goto out_detach;
+	if (resv_msi) {
+		ret = iommu_get_msi_cookie(domain->domain, resv_msi_base);
+		if (ret)
+			goto out_detach;
+	}
 
 	list_add(&domain->next, &iommu->domain_list);