From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH] nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine Date: Sat, 20 Jan 2024 10:56:06 +0100 [thread overview] Message-ID: <6d2b8c390907dcac2e4dc6e71f1b2db2ef8abef1.1705744530.git.christophe.jaillet@wanadoo.fr> (raw) 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@wanadoo.fr> --- 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
WARNING: multiple messages have this Message-ID (diff)
From: Christophe JAILLET <christophe.jaillet@wanadoo.fr> To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET <christophe.jaillet@wanadoo.fr>, netdev@vger.kernel.org Subject: [PATCH RESEND] nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine Date: Sat, 27 Jan 2024 10:58:29 +0100 [thread overview] Message-ID: <6d2b8c390907dcac2e4dc6e71f1b2db2ef8abef1.1705744530.git.christophe.jaillet@wanadoo.fr> (raw) Message-ID: <20240127095829.8o5g88a-v7C3HzYZlsa4SJduGH9lJakUdqfTVqWXT2M@z> (raw) 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@wanadoo.fr> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org> --- 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@linaro.org/ --- 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
next reply other threads:[~2024-01-20 9:56 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-01-20 9:56 Christophe JAILLET [this message] 2024-01-20 12:00 ` [PATCH] nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine Simon Horman 2024-01-23 13:24 ` Krzysztof Kozlowski 2024-01-27 9:58 ` [PATCH RESEND] " Christophe JAILLET 2024-01-31 23:08 ` Jakub Kicinski 2024-02-02 19:11 ` Christophe JAILLET 2024-02-02 19:33 ` Jakub Kicinski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=6d2b8c390907dcac2e4dc6e71f1b2db2ef8abef1.1705744530.git.christophe.jaillet@wanadoo.fr \ --to=christophe.jaillet@wanadoo.fr \ --cc=davem@davemloft.net \ --cc=edumazet@google.com \ --cc=kernel-janitors@vger.kernel.org \ --cc=krzysztof.kozlowski@linaro.org \ --cc=kuba@kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=netdev@vger.kernel.org \ --cc=pabeni@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).