Skip to contentSkip to conversation

drm/tegra: checking IS_ERR() instead of NULL

PATCH In review Dan Carpenter 3 participants 4 messages Dec 4, 2014 – Dec 5, 2014 2 messages not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/tegra: checking IS_ERR() instead of NULL

iommu_domain_alloc() returns NULL on error, it never returns error pointers.

drivers/gpu/drm/tegra/drm.c +2 -2
index e549afe..fa16048 100644
@@ -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;
 		}
 
#1 lore raw
Quoted 10 lines · Dan Carpenter

iommu_domain_alloc() returns NULL on error, it never returns error pointers.

drivers/gpu/drm/tegra/drm.c +0 -0
index e549afe..fa16048 100644

drivers/gpu/drm/tegra/drm.c static int tegra_drm_load(struct drm_device *drm, unsigned long flags) · line 42

Quoted 9 lines
drivers/gpu/drm/tegra/drm.c +2 -2
@@ -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

A message that is not in the archive (sent off-list or not yet received): 20141204132349.GD7262-AwZRO8vwLAwmlAP/[email protected]

#3 lore raw
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/tegra/drm.c +0 -0
index e549afe..fa16048 100644
@@ -36,8 +36,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 
Quoted 10 lines

drivers/gpu/drm/tegra/drm.c static int tegra_drm_load(struct drm_device *drm, unsigned long flags) · line 42

Quoted 8 lines
drivers/gpu/drm/tegra/drm.c +2 -2
 	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

A message that is not in the archive (sent off-list or not yet received): 54819FFF.4000907-Rn4VEauK+AKRv+LV9MX5uipxlwaOVQ5f@public.gmane.org

#5 lore raw
Quoted 17 lines · SF Markus Elfring
Quoted 6 lines
Quoted 6 lines
drivers/gpu/drm/tegra/drm.c +0 -0
index e549afe..fa16048 100644
@@ -36,8 +36,8 @@ static int tegra_drm_load(struct drm_device *drm, unsigned long flags)
 
Quoted 10 lines

drivers/gpu/drm/tegra/drm.c static int tegra_drm_load(struct drm_device *drm, unsigned long flags) · line 42

Quoted 8 lines
drivers/gpu/drm/tegra/drm.c +2 -2
 	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.

Quoted 4 lines

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