[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 2 Feb 2024 20:11:56 +0100
From: Christophe JAILLET <christophe.jaillet@...adoo.fr>
To: Jakub Kicinski <kuba@...nel.org>
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Paolo Abeni <pabeni@...hat.com>, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH RESEND] nfc: hci: Save a few bytes of memory when
registering a 'nfc_llc' engine
Le 01/02/2024 à 00:08, Jakub Kicinski a écrit :
> On Sat, 27 Jan 2024 10:58:29 +0100 Christophe JAILLET wrote:
>> 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@...adoo.fr>
>> Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@...aro.org>
>
> There is a kfree() call in nfc_llc_exit() that looks suspiciously
> like it may also free the name.
>
>
Hi,
you are right.
Should we have something like:
void nfc_llc_exit(void)
{
struct nfc_llc_engine *llc_engine, *n;
list_for_each_entry_safe(llc_engine, n, &llc_engines, entry)
nfc_llc_unregister(&llc_engine->name);
}
It would be slower, but it would reduce code duplication as well.
This is just an _exit() function, so it shouldn't be called that often
anyway, if called at all.
Or, add another function with the list_del()+kfree_const()+kfree(), that
would be called from nfc_llc_exit() and nfc_llc_unregister(), to have
the best of the 2 worlds?
CJ
Powered by blists - more mailing lists