[PATCH RESEND] nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine
From: Christophe JAILLET
Date: Sat Jan 27 2024 - 05:00:03 EST
nfc_llc_register() calls pass a string literal as the 'name' parameter.
So kstrdup_const() can be used instead of kfree() to avoid a memory
allocation in such cases.
Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
---
Resent because of 'net-next-closed' message on previous try.
Added R-b tag. (see [1])
[1]: https://lore.kernel.org/all/9415e571-50a1-41d3-8205-68e4128bbe6d@xxxxxxxxxx/
---
net/nfc/hci/llc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/nfc/hci/llc.c b/net/nfc/hci/llc.c
index 2140f6724644..8c7b5a817b25 100644
--- a/net/nfc/hci/llc.c
+++ b/net/nfc/hci/llc.c
@@ -49,7 +49,7 @@ int nfc_llc_register(const char *name, const struct nfc_llc_ops *ops)
if (llc_engine == NULL)
return -ENOMEM;
- llc_engine->name = kstrdup(name, GFP_KERNEL);
+ llc_engine->name = kstrdup_const(name, GFP_KERNEL);
if (llc_engine->name == NULL) {
kfree(llc_engine);
return -ENOMEM;
@@ -83,7 +83,7 @@ void nfc_llc_unregister(const char *name)
return;
list_del(&llc_engine->entry);
- kfree(llc_engine->name);
+ kfree_const(llc_engine->name);
kfree(llc_engine);
}
--
2.43.0