diff mbox series

HID: logitech-hidpp: Replace devm_kasprintf() call by devm_kstrdup() in hidpp_connect_event()

Message ID 99e0a0e0-1b21-4e94-a9ff-2dc5715d676d@web.de
State New
Headers show
Series HID: logitech-hidpp: Replace devm_kasprintf() call by devm_kstrdup() in hidpp_connect_event() | expand

Commit Message

Markus Elfring April 16, 2025, 1:32 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 16 Apr 2025 15:25:05 +0200

Use a devm_kstrdup() call instead of a devm_kasprintf() call
in this function implementation because only a single string
should be copied.

The source code was transformed by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/hid/hid-logitech-hidpp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c
index 10a3bc5f931b..c1a9ecde57c6 100644
--- a/drivers/hid/hid-logitech-hidpp.c
+++ b/drivers/hid/hid-logitech-hidpp.c
@@ -4216,8 +4216,7 @@  static void hidpp_connect_event(struct work_struct *work)
 	if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) {
 		name = hidpp_get_device_name(hidpp);
 		if (name) {
-			devm_name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
-						   "%s", name);
+			devm_name = devm_kstrdup(&hdev->dev, name, GFP_KERNEL);
 			kfree(name);
 			if (!devm_name)
 				return;