All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Ben Skeggs <bskeggs@redhat.com>, David Airlie <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	nouveau <nouveau@lists.freedesktop.org>
Subject: Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
Date: Wed, 12 May 2021 14:57:23 +0800	[thread overview]
Message-ID: <0800f5b6-ff18-94eb-a4a0-113800a9b14d@huawei.com> (raw)
In-Reply-To: <20210512063952.5kwdrq2yzbmgmn4x@Normandy.localdomain>



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

WARNING: multiple messages have this Message-ID (diff)
From: "Leizhen (ThunderTown)" <thunder.leizhen@huawei.com>
To: Ben Skeggs <bskeggs@redhat.com>, David Airlie <airlied@linux.ie>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	nouveau <nouveau@lists.freedesktop.org>
Subject: Re: [Nouveau] [PATCH v2 1/2] drm/nouveau: Fix ida leak
Date: Wed, 12 May 2021 14:57:23 +0800	[thread overview]
Message-ID: <0800f5b6-ff18-94eb-a4a0-113800a9b14d@huawei.com> (raw)
In-Reply-To: <20210512063952.5kwdrq2yzbmgmn4x@Normandy.localdomain>



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
> 
> .
> 


  reply	other threads:[~2021-05-13 20:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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) [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=0800f5b6-ff18-94eb-a4a0-113800a9b14d@huawei.com \
    --to=thunder.leizhen@huawei.com \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.