✓ CI.checkpatch: success for drm/i915/backlight: Remove a useless kstrdup_const()
Patchwork
patchwork at emeril.freedesktop.org
Sat Sep 28 14:43:49 UTC 2024
== Series Details ==
Series: drm/i915/backlight: Remove a useless kstrdup_const()
URL : https://patchwork.freedesktop.org/series/139245/
State : success
== Summary ==
+ KERNEL=/kernel
+ git clone https://gitlab.freedesktop.org/drm/maintainer-tools mt
Cloning into 'mt'...
warning: redirecting to https://gitlab.freedesktop.org/drm/maintainer-tools.git/
+ git -C mt rev-list -n1 origin/master
30ab6715fc09baee6cc14cb3c89ad8858688d474
+ cd /kernel
+ git config --global --add safe.directory /kernel
+ git log -n1
commit ef4ba7e2e7a0a804aba4b7a2a36a048d904384ec
Author: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
Date: Sat Sep 28 16:28:24 2024 +0200
drm/i915/backlight: Remove a useless kstrdup_const()
"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.
Signed-off-by: Christophe JAILLET <christophe.jaillet at wanadoo.fr>
+ /mt/dim checkpatch 26055f21c653a310af74417fe81466cb3ede668c drm-intel
ef4ba7e2e7a0 drm/i915/backlight: Remove a useless kstrdup_const()
More information about the Intel-xe
mailing list