Skip to content

Commit

Permalink
drm/i915/display: Save a few bytes of memory in intel_backlight_devic…
Browse files Browse the repository at this point in the history
…e_register()

'name' may still be "intel_backlight" when backlight_device_register()
is called. In such a case, using kstrdup_const() saves a memory
duplication when dev_set_name() is called in
backlight_device_register().

Use kfree_const() accordingly.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/ecfdb3af5005e05131e2fb93fd870830f39a8c29.1708708142.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
  • Loading branch information
Christophe JAILLET authored and Jani Nikula committed Feb 29, 2024
1 parent a1789b3 commit 379b63e
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/gpu/drm/i915/display/intel_backlight.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ int intel_backlight_device_register(struct intel_connector *connector)
else
props.power = FB_BLANK_POWERDOWN;

name = kstrdup("intel_backlight", GFP_KERNEL);
name = kstrdup_const("intel_backlight", GFP_KERNEL);
if (!name)
return -ENOMEM;

Expand All @@ -963,7 +963,7 @@ int intel_backlight_device_register(struct intel_connector *connector)
* compatibility. Use unique names for subsequent backlight devices as a
* fallback when the default name already exists.
*/
kfree(name);
kfree_const(name);
name = kasprintf(GFP_KERNEL, "card%d-%s-backlight",
i915->drm.primary->index, connector->base.name);
if (!name)
Expand All @@ -987,7 +987,7 @@ int intel_backlight_device_register(struct intel_connector *connector)
connector->base.base.id, connector->base.name, name);

out:
kfree(name);
kfree_const(name);

return ret;
}
Expand Down

0 comments on commit 379b63e

Please sign in to comment.