Skip to contentSkip to conversation

drm/nouveau: fix an error code in nouveau_backlight_init()

PATCH Superseded Dan Carpenter 2 participants 2 messages Apr 14, 2021 – Apr 19, 2021

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/nouveau: fix an error code in nouveau_backlight_init()

If nouveau_get_backlight_name() fails then this should return -ENOMEM but currently it returns success.

Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")

---
This is from static analysis. In the original commit db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces") then returning zero seemed to be a very deliberate choice. I do think it was wrong though and -ENOMEM is the currect return.

 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..3786b1c85182 100644
@@ -274,6 +274,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
+		ret = -ENOMEM;
 		goto fail_alloc;
 	}
 
Signature · 6 lines
2.30.2

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Reviewed-by on v1 1/1
#1 lore raw

I can not remember why the original code did return 0 rather than an error, but -ENOMEM seems indeed way more fitting.

Quoted 33 lines · Dan Carpenter

If nouveau_get_backlight_name() fails then this should return -ENOMEM but currently it returns success.

Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")

---
This is from static analysis. In the original commit db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces") then returning zero seemed to be a very deliberate choice. I do think it was wrong though and -ENOMEM is the currect return.

 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..3786b1c85182 100644
@@ -274,6 +274,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
+		ret = -ENOMEM;
 		goto fail_alloc;
 	}
 
Signature · 6 lines
2.30.2

_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau