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

Jani Nikula jani.nikula at linux.intel.com
Wed Oct 2 11:51:51 UTC 2024


On Tue, 01 Oct 2024, Christophe JAILLET <christophe.jaillet at wanadoo.fr> wrote:
> Le 30/09/2024 à 09:48, Jani Nikula a écrit :
>> On Sat, 28 Sep 2024, Christophe JAILLET <christophe.jaillet at wanadoo.fr> 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.


-- 
Jani Nikula, Intel


More information about the Intel-gfx mailing list