diff mbox series

[-next] iommu/tegra-smmu: Fix return value check in tegra_smmu_group_get()

Message ID 1513739169-122341-1-git-send-email-weiyongjun1@huawei.com
State Accepted
Headers show
Series [-next] iommu/tegra-smmu: Fix return value check in tegra_smmu_group_get() | expand

Commit Message

Wei Yongjun Dec. 20, 2017, 3:06 a.m. UTC
In case of error, the function iommu_group_alloc() returns ERR_PTR() and
never returns NULL. The NULL test in the return value check should be
replaced with IS_ERR().

Fixes: 7f4c9176f760 ("iommu/tegra: Allow devices to be grouped")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/iommu/tegra-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


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

Comments

Alex Williamson Dec. 20, 2017, 4:44 p.m. UTC | #1
On Wed, 20 Dec 2017 03:06:09 +0000
Wei Yongjun <weiyongjun1@huawei.com> wrote:

> In case of error, the function iommu_group_alloc() returns ERR_PTR() and
> never returns NULL. The NULL test in the return value check should be
> replaced with IS_ERR().
> 
> Fixes: 7f4c9176f760 ("iommu/tegra: Allow devices to be grouped")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/iommu/tegra-smmu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> index 8885635..44d40bc 100644
> --- a/drivers/iommu/tegra-smmu.c
> +++ b/drivers/iommu/tegra-smmu.c
> @@ -832,7 +832,7 @@ static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,
>  	group->soc = soc;
>  
>  	group->group = iommu_group_alloc();
> -	if (!group->group) {
> +	if (IS_ERR(group->group)) {
>  		devm_kfree(smmu->dev, group);
>  		mutex_unlock(&smmu->lock);
>  		return NULL;

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

Thierry, I assume you'll add this on top of the referenced commit.
Thanks,

Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Thierry Reding Dec. 20, 2017, 5:41 p.m. UTC | #2
On Wed, Dec 20, 2017 at 09:44:00AM -0700, Alex Williamson wrote:
> On Wed, 20 Dec 2017 03:06:09 +0000
> Wei Yongjun <weiyongjun1@huawei.com> wrote:
> 
> > In case of error, the function iommu_group_alloc() returns ERR_PTR() and
> > never returns NULL. The NULL test in the return value check should be
> > replaced with IS_ERR().
> > 
> > Fixes: 7f4c9176f760 ("iommu/tegra: Allow devices to be grouped")
> > Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> > ---
> >  drivers/iommu/tegra-smmu.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
> > index 8885635..44d40bc 100644
> > --- a/drivers/iommu/tegra-smmu.c
> > +++ b/drivers/iommu/tegra-smmu.c
> > @@ -832,7 +832,7 @@ static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,
> >  	group->soc = soc;
> >  
> >  	group->group = iommu_group_alloc();
> > -	if (!group->group) {
> > +	if (IS_ERR(group->group)) {
> >  		devm_kfree(smmu->dev, group);
> >  		mutex_unlock(&smmu->lock);
> >  		return NULL;
> 
> Acked-by: Alex Williamson <alex.williamson@redhat.com>
> 
> Thierry, I assume you'll add this on top of the referenced commit.
> Thanks,

Applied, thanks.

Thierry
diff mbox series

Patch

diff --git a/drivers/iommu/tegra-smmu.c b/drivers/iommu/tegra-smmu.c
index 8885635..44d40bc 100644
--- a/drivers/iommu/tegra-smmu.c
+++ b/drivers/iommu/tegra-smmu.c
@@ -832,7 +832,7 @@  static struct iommu_group *tegra_smmu_group_get(struct tegra_smmu *smmu,
 	group->soc = soc;
 
 	group->group = iommu_group_alloc();
-	if (!group->group) {
+	if (IS_ERR(group->group)) {
 		devm_kfree(smmu->dev, group);
 		mutex_unlock(&smmu->lock);
 		return NULL;