Skip to contentSkip to conversation

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

PATCH In review Zhen Lei 2 participants 3 messages May 8, 2021

Subsystems (3)
lore
Share & tools
lore

Zhen Lei

author
#0 lore raw

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

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

Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")
---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..097ca344a086 100644
@@ -273,6 +273,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 		return -ENOMEM;
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
+		ret = -ENOSPC;
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
 		goto fail_alloc;
 	}
Signature · 1 line
2.25.1
#1 lore raw

Hello Zhen,

There was a similar patch sent in last month, though which does not seem to have been merged yet; see
https://lists.freedesktop.org/archives/nouveau/2021-April/038451.html.

Whether ret should be -ENOSPC or -ENOMEM is hard to say as nouveau_get_backlight_name() could fail due to either.

I will propose an alternative fix which modifies nouveau_get_backlight_name() to return an int so the actual error code can be propagated back instead of guessed, as well as fix an ida ID leak which I just spotted.

Best,
Pierre

Quoted 26 lines · Zhen Lei

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

Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")
---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..097ca344a086 100644
@@ -273,6 +273,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 		return -ENOMEM;
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
+		ret = -ENOSPC;
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
 		goto fail_alloc;
 	}
Signature · 1 line
2.25.1

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

#2 lore raw
Quoted 6 lines · Pierre Moreau

Hello Zhen,

There was a similar patch sent in last month, though which does not seem to have been merged yet; see
https://lists.freedesktop.org/archives/nouveau/2021-April/038451.html.

Quoted 6 lines

Whether ret should be -ENOSPC or -ENOMEM is hard to say as nouveau_get_backlight_name() could fail due to either.

I will propose an alternative fix which modifies nouveau_get_backlight_name() to return an int so the actual error code can be propagated back instead of guessed, as well as fix an ida ID leak which I just spotted.

It's a good idea.

Quoted 34 lines

Best,
Pierre

Quoted 26 lines · Zhen Lei

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

Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")
---
 drivers/gpu/drm/nouveau/nouveau_backlight.c | 1 +
 1 file changed, 1 insertion(+)
drivers/gpu/drm/nouveau/nouveau_backlight.c +1 -0
index 72f35a2babcb..097ca344a086 100644
@@ -273,6 +273,7 @@ nouveau_backlight_init(struct drm_connector *connector)
 		return -ENOMEM;
 
 	if (!nouveau_get_backlight_name(backlight_name, bl)) {
+		ret = -ENOSPC;
 		NV_ERROR(drm, "Failed to retrieve a unique name for the backlight interface\n");
 		goto fail_alloc;
 	}
Signature · 1 line
2.25.1

.