diff mbox

drm/tegra: checking IS_ERR() instead of NULL

Message ID 20141204110035.GC22643@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter Dec. 4, 2014, 11 a.m. UTC
iommu_domain_alloc() returns NULL on error, it never returns error
pointers.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Thierry Reding Dec. 4, 2014, 1:23 p.m. UTC | #1
On Thu, Dec 04, 2014 at 02:00:35PM +0300, Dan Carpenter wrote:
> iommu_domain_alloc() returns NULL on error, it never returns error
> pointers.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> index e549afe..fa16048 100644
> --- a/drivers/gpu/drm/tegra/drm.c
> +++ b/drivers/gpu/drm/tegra/drm.c
> @@ -36,8 +36,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
>  
>  	if (iommu_present(&platform_bus_type)) {
>  		tegra->domain = iommu_domain_alloc(&platform_bus_type);
> -		if (IS_ERR(tegra->domain)) {
> -			err = PTR_ERR(tegra->domain);
> +		if (!tegra->domain) {
> +			err = -ENOMEM;
>  			goto free;
>  		}

Oh, good catch. Applied, thanks.

Thierry
SF Markus Elfring Dec. 5, 2014, 12:07 p.m. UTC | #2
>> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
>> index e549afe..fa16048 100644
>> --- a/drivers/gpu/drm/tegra/drm.c
>> +++ b/drivers/gpu/drm/tegra/drm.c
>> @@ -36,8 +36,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
>>  
>>  	if (iommu_present(&platform_bus_type)) {
>>  		tegra->domain = iommu_domain_alloc(&platform_bus_type);
>> -		if (IS_ERR(tegra->domain)) {
>> -			err = PTR_ERR(tegra->domain);
>> +		if (!tegra->domain) {
>> +			err = -ENOMEM;
>>  			goto free;
>>  		}
> 
> Oh, good catch. Applied, thanks.

How do you think about to amend the commit title?

Is the following wording more appropriate?
drm/tegra: Checking for NULL pointer instead of IS_ERR() usage

Regards,
Markus
Thierry Reding Dec. 5, 2014, 1:19 p.m. UTC | #3
On Fri, Dec 05, 2014 at 01:07:27PM +0100, SF Markus Elfring wrote:
> >> diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
> >> index e549afe..fa16048 100644
> >> --- a/drivers/gpu/drm/tegra/drm.c
> >> +++ b/drivers/gpu/drm/tegra/drm.c
> >> @@ -36,8 +36,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
> >>  
> >>  	if (iommu_present(&platform_bus_type)) {
> >>  		tegra->domain = iommu_domain_alloc(&platform_bus_type);
> >> -		if (IS_ERR(tegra->domain)) {
> >> -			err = PTR_ERR(tegra->domain);
> >> +		if (!tegra->domain) {
> >> +			err = -ENOMEM;
> >>  			goto free;
> >>  		}
> > 
> > Oh, good catch. Applied, thanks.
> 
> How do you think about to amend the commit title?
> 
> Is the following wording more appropriate?
> drm/tegra: Checking for NULL pointer instead of IS_ERR() usage

Sounds better yes. I've gone with:

	drm/tegra: Check for NULL pointer instead of IS_ERR()

Thierry
diff mbox

Patch

diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c
index e549afe..fa16048 100644
--- a/drivers/gpu/drm/tegra/drm.c
+++ b/drivers/gpu/drm/tegra/drm.c
@@ -36,8 +36,8 @@  static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 
 	if (iommu_present(&platform_bus_type)) {
 		tegra->domain = iommu_domain_alloc(&platform_bus_type);
-		if (IS_ERR(tegra->domain)) {
-			err = PTR_ERR(tegra->domain);
+		if (!tegra->domain) {
+			err = -ENOMEM;
 			goto free;
 		}