* [Nouveau] [PATCH v2 0/2] Fix ida leak and error return code
@ 2021-05-11 8:28 ` Zhen Lei
0 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: Zhen Lei
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(-)
--
2.26.0.106.g9fadedd
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v2 0/2] Fix ida leak and error return code
@ 2021-05-11 8:28 ` Zhen Lei
0 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: Zhen Lei
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(-)
--
2.26.0.106.g9fadedd
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
2021-05-11 8:28 ` Zhen Lei
@ 2021-05-11 8:28 ` Zhen Lei
-1 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: 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 <thunder.leizhen@huawei.com>
---
drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 72f35a2babcb20e..d1c998e645fb4b6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -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);
--
2.26.0.106.g9fadedd
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 1/2] drm/nouveau: Fix ida leak
@ 2021-05-11 8:28 ` Zhen Lei
0 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: 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 <thunder.leizhen@huawei.com>
---
drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index 72f35a2babcb20e..d1c998e645fb4b6 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -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);
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [Nouveau] [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init()
2021-05-11 8:28 ` Zhen Lei
@ 2021-05-11 8:28 ` Zhen Lei
-1 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: 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 <pierre.morrow@free.fr>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index d1c998e645fb4b6..f0856adbe775624 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -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;
}
--
2.26.0.106.g9fadedd
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init()
@ 2021-05-11 8:28 ` Zhen Lei
0 siblings, 0 replies; 12+ messages in thread
From: Zhen Lei @ 2021-05-11 8:28 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, Pierre Moreau,
dri-devel, nouveau
Cc: 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 <pierre.morrow@free.fr>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
---
drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
index d1c998e645fb4b6..f0856adbe775624 100644
--- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
+++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
@@ -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;
}
--
2.26.0.106.g9fadedd
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init()
2021-05-11 8:28 ` Zhen Lei
@ 2021-05-12 6:34 ` Pierre Moreau
-1 siblings, 0 replies; 12+ messages in thread
From: Pierre Moreau @ 2021-05-12 6:34 UTC (permalink / raw)
To: Zhen Lei; +Cc: David Airlie, nouveau, dri-devel, Ben Skeggs, Daniel Vetter
Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
On 2021-05-11 — 16:28, Zhen Lei wrote:
> 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 <pierre.morrow@free.fr>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index d1c998e645fb4b6..f0856adbe775624 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -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;
> }
> --
> 2.26.0.106.g9fadedd
>
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init()
@ 2021-05-12 6:34 ` Pierre Moreau
0 siblings, 0 replies; 12+ messages in thread
From: Pierre Moreau @ 2021-05-12 6:34 UTC (permalink / raw)
To: Zhen Lei; +Cc: David Airlie, nouveau, dri-devel, Ben Skeggs
Reviewed-by: Pierre Moreau <pierre.morrow@free.fr>
On 2021-05-11 — 16:28, Zhen Lei wrote:
> 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 <pierre.morrow@free.fr>
> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_backlight.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index d1c998e645fb4b6..f0856adbe775624 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -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;
> }
> --
> 2.26.0.106.g9fadedd
>
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
2021-05-11 8:28 ` Zhen Lei
@ 2021-05-12 6:39 ` Pierre Moreau
-1 siblings, 0 replies; 12+ messages in thread
From: Pierre Moreau @ 2021-05-12 6:39 UTC (permalink / raw)
To: Zhen Lei; +Cc: David Airlie, nouveau, dri-devel, Ben Skeggs, Daniel Vetter
Why remove the const modifier on `nb`?
On 2021-05-11 — 16:28, Zhen Lei wrote:
> 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 <thunder.leizhen@huawei.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index 72f35a2babcb20e..d1c998e645fb4b6 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -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);
> --
> 2.26.0.106.g9fadedd
>
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
@ 2021-05-12 6:39 ` Pierre Moreau
0 siblings, 0 replies; 12+ messages in thread
From: Pierre Moreau @ 2021-05-12 6:39 UTC (permalink / raw)
To: Zhen Lei; +Cc: David Airlie, nouveau, dri-devel, Ben Skeggs
Why remove the const modifier on `nb`?
On 2021-05-11 — 16:28, Zhen Lei wrote:
> 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 <thunder.leizhen@huawei.com>
> ---
> drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> index 72f35a2babcb20e..d1c998e645fb4b6 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
> @@ -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);
> --
> 2.26.0.106.g9fadedd
>
>
> _______________________________________________
> Nouveau mailing list
> Nouveau@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
2021-05-12 6:39 ` Pierre Moreau
@ 2021-05-12 6:57 ` Leizhen (ThunderTown)
-1 siblings, 0 replies; 12+ messages in thread
From: Leizhen (ThunderTown) @ 2021-05-12 6:57 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, dri-devel, nouveau
On 2021/5/12 14:39, Pierre Moreau wrote:
> 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.
>
> On 2021-05-11 — 16:28, Zhen Lei wrote:
>> 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 <thunder.leizhen@huawei.com>
>> ---
>> drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> index 72f35a2babcb20e..d1c998e645fb4b6 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> @@ -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);
>> --
>> 2.26.0.106.g9fadedd
>>
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau
>
> .
>
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
@ 2021-05-12 6:57 ` Leizhen (ThunderTown)
0 siblings, 0 replies; 12+ messages in thread
From: Leizhen (ThunderTown) @ 2021-05-12 6:57 UTC (permalink / raw)
To: Ben Skeggs, David Airlie, Daniel Vetter, dri-devel, nouveau
On 2021/5/12 14:39, Pierre Moreau wrote:
> 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.
>
> On 2021-05-11 — 16:28, Zhen Lei wrote:
>> 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 <thunder.leizhen@huawei.com>
>> ---
>> drivers/gpu/drm/nouveau/nouveau_backlight.c | 5 +++--
>> 1 file changed, 3 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/nouveau/nouveau_backlight.c b/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> index 72f35a2babcb20e..d1c998e645fb4b6 100644
>> --- a/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> +++ b/drivers/gpu/drm/nouveau/nouveau_backlight.c
>> @@ -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);
>> --
>> 2.26.0.106.g9fadedd
>>
>>
>> _______________________________________________
>> Nouveau mailing list
>> Nouveau@lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/nouveau
>
> .
>
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-05-13 20:26 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-11 8:28 [Nouveau] [PATCH v2 0/2] Fix ida leak and error return code Zhen Lei
2021-05-11 8:28 ` Zhen Lei
2021-05-11 8:28 ` [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak Zhen Lei
2021-05-11 8:28 ` Zhen Lei
2021-05-12 6:39 ` [Nouveau] " Pierre Moreau
2021-05-12 6:39 ` Pierre Moreau
2021-05-12 6:57 ` Leizhen (ThunderTown)
2021-05-12 6:57 ` Leizhen (ThunderTown)
2021-05-11 8:28 ` [Nouveau] [PATCH v2 2/2] drm/nouveau: Fix error return code in nouveau_backlight_init() Zhen Lei
2021-05-11 8:28 ` Zhen Lei
2021-05-12 6:34 ` [Nouveau] " Pierre Moreau
2021-05-12 6:34 ` Pierre Moreau
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.