Fix ida leak and error return code
Subsystems (3)
v2 cover Fix ida leak and error return code
v1 --> v2:
1. Add Patch 1 to fix ida leak
2. Modifies nouveau_get_backlight_name() to propagate the actual error code
Zhen Lei (2):
drm/nouveau: Fix ida leak
drm/nouveau: Fix error return code in nouveau_backlight_init()
drivers/gpu/drm/nouveau/nouveau_backlight.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
Signature · 1 line
2.26.0.106.g9fadedd
PATCH v2 1/2 drm/nouveau: Fix ida leak
When the 'nb' value allocated from 'bl_ida' is greater than or equal to 100, it will not be released. In fact, we can simplify operations by limiting the range of idas that can be applied for.
By the way, delete the const modifier of the local variable 'nb'.
--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +3 -2
@@ -51,8 +51,9 @@ static bool nouveau_get_backlight_name(char backlight_name[BL_NAME_SIZE], struct nouveau_backlight *bl) { - const int nb = ida_simple_get(&bl_ida, 0, 0, GFP_KERNEL); -if (nb <0 || nb >=100 ) + int nb = ida_simple_get(&bl_ida, 0, 100, GFP_KERNEL); + +if (nb <0 )return false;if (nb >0 )snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight%d" , nb);
Signature · 1 line
2.26.0.106.g9fadedd
Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
Why remove the const modifier on nb?
Quoted 36 lines · Zhen Lei
When the 'nb' value allocated from '
bl_ida' is greater than or equal to 100, it will not be released. In fact, we can simplify operations by limiting the range of idas that can be applied for.By the way, delete the const modifier of the local variable 'nb'.
Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")Signed-off-by Zhen Lei <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_backlight.c +3
-2@@ -51,8 +51,9 @@ static bool nouveau_get_backlight_name(char backlight_name[BL_NAME_SIZE], struct nouveau_backlight *bl) { - const int nb = ida_simple_get(&bl_ida, 0, 0, GFP_KERNEL); -if (nb <0 || nb >=100 ) + int nb = ida_simple_get(&bl_ida, 0, 100, GFP_KERNEL); + +if (nb <0 )return false;if (nb >0 )snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight%d" , nb);Signature · 7 lines
2.26.0.106.g9fadedd _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
Quoted 1 line · Pierre Moreau
Why remove the const modifier on
nb?
A non-pointer local variable, I don't think it's necessary to add const modifier to make the syntax too complicated.
Quoted 41 lines · Zhen Lei
Quoted 36 lines
When the 'nb' value allocated from '
bl_ida' is greater than or equal to 100, it will not be released. In fact, we can simplify operations by limiting the range of idas that can be applied for.By the way, delete the const modifier of the local variable 'nb'.
Fixes db1a0ae21461 ("drm/nouveau/bl: Assign different names to interfaces")Signed-off-by Zhen Lei <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpu/drm/nouveau/nouveau_backlight.c +3
-2@@ -51,8 +51,9 @@ static bool nouveau_get_backlight_name(char backlight_name[BL_NAME_SIZE], struct nouveau_backlight *bl) { - const int nb = ida_simple_get(&bl_ida, 0, 0, GFP_KERNEL); -if (nb <0 || nb >=100 ) + int nb = ida_simple_get(&bl_ida, 0, 100, GFP_KERNEL); + +if (nb <0 )return false;if (nb >0 )snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight%d" , nb);Signature · 7 lines
2.26.0.106.g9fadedd _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau.
PATCH v2 2/2 drm/nouveau: Fix error return code in nouveau_backlight_init()
In reply to Zhen LeiFix to return a negative error code from the error handling case instead of 0, as done elsewhere in this function.
--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/nouveau/nouveau_backlight.c +5 -4
@@ -47,20 +47,20 @@ struct nouveau_backlight {int id; }; -static bool +static int nouveau_get_backlight_name (char backlight_name[BL_NAME_SIZE ],struct nouveau_backlight *bl) {int nb =ida_simple_get (&bl_ida,0 ,100 ,GFP_KERNEL );if (nb <0 ) -return false; +return nb;if (nb >0 )snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight%d" , nb);else snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight" ); bl->id = nb; -return true; +return 0 ; } static int
@@ -273,7 +273,8 @@ nouveau_backlight_init(struct drm_connector *connector)if (!bl)return -ENOMEM ; -if (!nouveau_get_backlight_name (backlight_name, bl)) { + ret =nouveau_get_backlight_name (backlight_name, bl); +if (ret) {NV_ERROR (drm,"Failed to retrieve a unique name for the backlight interface\n" ); goto fail_alloc; }
Signature · 1 line
2.26.0.106.g9fadedd
Re: [Nouveau] [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init()
Quoted 56 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")Suggested-by Pierre Moreau <[email protected]>Signed-off-by Zhen Lei <[email protected]>--- drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)drivers/gpu/drm/nouveau/nouveau_backlight.c +5
-4@@ -47,20 +47,20 @@ struct nouveau_backlight {int id; }; -static bool +static int nouveau_get_backlight_name (char backlight_name[BL_NAME_SIZE ],struct nouveau_backlight *bl) {int nb =ida_simple_get (&bl_ida,0 ,100 ,GFP_KERNEL );if (nb <0 ) -return false; +return nb;if (nb >0 )snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight%d" , nb);else snprintf (backlight_name,BL_NAME_SIZE ,"nv_backlight" ); bl->id = nb; -return true; +return 0 ; } static int@@ -273,7 +273,8 @@ nouveau_backlight_init(struct drm_connector *connector)if (!bl)return -ENOMEM ; -if (!nouveau_get_backlight_name (backlight_name, bl)) { + ret =nouveau_get_backlight_name (backlight_name, bl); +if (ret) {NV_ERROR (drm,"Failed to retrieve a unique name for the backlight interface\n" ); goto fail_alloc; }Signature · 7 lines
2.26.0.106.g9fadedd _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/nouveau