Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine

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>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Christophe JAILLET and committed by
Paolo Abeni
83cdd8db d6f4aac1

+2 -2
+2 -2
net/nfc/hci/llc.c
··· 33 33 static void nfc_llc_del_engine(struct nfc_llc_engine *llc_engine) 34 34 { 35 35 list_del(&llc_engine->entry); 36 - kfree(llc_engine->name); 36 + kfree_const(llc_engine->name); 37 37 kfree(llc_engine); 38 38 } 39 39 ··· 53 53 if (llc_engine == NULL) 54 54 return -ENOMEM; 55 55 56 - llc_engine->name = kstrdup(name, GFP_KERNEL); 56 + llc_engine->name = kstrdup_const(name, GFP_KERNEL); 57 57 if (llc_engine->name == NULL) { 58 58 kfree(llc_engine); 59 59 return -ENOMEM;