Re: [PATCH] drm/i915/backlight: Remove a useless kstrdup_const()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 02/10/2024 à 13:51, Jani Nikula a écrit :
On Tue, 01 Oct 2024, Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> wrote:
Le 30/09/2024 à 09:48, Jani Nikula a écrit :
On Sat, 28 Sep 2024, Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> wrote:
"name" is allocated and freed in intel_backlight_device_register().
The initial allocation just duplicates "intel_backlight".

Later, if a device with this name has already been registered, another
dynamically generated one is allocated using kasprintf().

So at the end of the function, when "name" is freed, it can point either to
the initial static literal "intel_backlight" or to the kasprintf()'ed one.

So kfree_const() is used.

However, when built as a module, kstrdup_const() and kfree_const() don't
work as one would expect and are just plain kstrdup() and kfree().


Slightly change the logic and introduce a new variable to hold the
address returned by kasprintf() should it be used.

This saves a memory allocation/free and avoids these _const functions,
which names can be confusing when used with code built as module.

Okay, I'd rather revert your earlier commit 379b63e7e682
("drm/i915/display: Save a few bytes of memory in
intel_backlight_device_register()") than add this.

Hi,

that works for me. Thanks and sorry for the noise.

Will you send the revert?

BR,
Jani.



Will do.

CJ




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux