From patchwork Sat Feb 3 07:51:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christophe JAILLET X-Patchwork-Id: 196202 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp899475dyc; Fri, 2 Feb 2024 23:53:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IF5twKVoGAfrBpSh++O9cEtMBdE3mZRFHsblPV9fqS63Xot4ddeUSbwK8qauwtargRWTkHR X-Received: by 2002:a0c:cb07:0:b0:68c:6cc2:5a8f with SMTP id o7-20020a0ccb07000000b0068c6cc25a8fmr458242qvk.54.1706946809923; Fri, 02 Feb 2024 23:53:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706946809; cv=pass; d=google.com; s=arc-20160816; b=hJXPdbifSWrQRrPzMF7JCd77xLgZ4HxCPcXo7ZEv2abe/tstTMYGyIOSyPMwntoXVN ns8oBQuWcxwI8hJKk9HEQYVzQK/SaPsR2l92zbr6QTjhWmL31JkiVBb/ylhM3nYtDR6o 2s31dsUVUK0/JgVfH0kOm5ewPHyQx65YO6HWdrvZSHbC5ABVSRx0YGta1ec8ZFnq+/Ev 5u4+TGnv4bqPC+o0y/q6yMH9JgMSKoHG2tVUm/wYMigl5v4pLXjyfp+emZHNieQjVwrh K1BRM1WdACG9B+H4IV4PooaO4+jSaqSTw0MpbKZ7VzSjASoZrs+MJm58mv0kC4xealn7 W+uQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=PvF+EwWrp7JXup44JQu6ssRQrUrUbuCCt5KLY27Imlo=; fh=I9IwSDBS9LOj3Qmc1L/34LmEjwfYADEVd4iOp/f6TZE=; b=NyFx5toVxKDlEMAP8Wul18r0SbxiYaWiQgg8YhQtnX5mtlYwOS03REElfSowEd95Fo aefp8OSwXrw/xN4YTsXTboiGkxoFBUbTl5ybhO8l+1+k5KLCgDf840dzofXbDI3OySPv Hzng+dfaxgRnqNr2uW+fVkwqKKVOKgjANfV81NFeuPUTQAZeLuqR3zVAfhodbyyfcBcE wS1r5wsBnFmTm219+LIepGchZ8nUoQm2gQmMMknruHQ02ym6Hlwq0Xa3TxGePGuN/GqC aaqKiukG1vTTrzVeeXGulyQuRCo5vcozuhi5xR67jbnJJD9OCnHXt0F08snhqhieZFfH gAQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=U2lmYnlY; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-50966-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50966-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr X-Forwarded-Encrypted: i=1; AJvYcCV8d50kNMP1VNMivCiquJB4+nFAqv0oJKY1AZ2m9r1M7cMWqEJVhDJ9dCrrAg5ipXSjiRzTMv8Q7xZWQDeZkCPoWxF6Wg== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z10-20020a0cfeca000000b0067f7b1f8f34si3755606qvs.242.2024.02.02.23.53.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Feb 2024 23:53:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-50966-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=U2lmYnlY; arc=pass (i=1 spf=pass spfdomain=wanadoo.fr dkim=pass dkdomain=wanadoo.fr dmarc=pass fromdomain=wanadoo.fr); spf=pass (google.com: domain of linux-kernel+bounces-50966-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-50966-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B47FF1C22B8B for ; Sat, 3 Feb 2024 07:53:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2688F4F8BE; Sat, 3 Feb 2024 07:52:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="U2lmYnlY" Received: from smtp.smtpout.orange.fr (smtp-18.smtpout.orange.fr [80.12.242.18]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 18CA24F5EA; Sat, 3 Feb 2024 07:52:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.18 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706946750; cv=none; b=KEVkGgv0T0kk4OCpCl8963q0BEa3rndETtRyBS6ZGuh+e0hO7ntIQz32NZQzYIFr2lCd4BsNgZwYuUwAFQxmGhuwfLAy5qJ/Kf500/JzDyKXLXZSZjpj1sdQdiHtBdnnPHtRHgyrO0KTGZFKVLlzkowK/eXIqVVpvqH25EwTiw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706946750; c=relaxed/simple; bh=haoge43Ne0oBEpD0h2wKsXPSAC+6OmzX0ZitPVb50po=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VUe8gLis0wbO5cnIVk1vofx9rue2i28BKEtY7+BtAIhqvS1XimI4ui3cJQYADNRhDT2+G3G4VfH6NqhHEbbIOzmd/srJcIDRkr3mK9AZcfe81FNyn3sEXkDk7Wr879uHSPF9QXOSA2kwjmQ37dpb6C44uS1MsqwrpRfR/AruVgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=U2lmYnlY; arc=none smtp.client-ip=80.12.242.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id WAnwrvC6Ki8tRWAoBrII3V; Sat, 03 Feb 2024 08:51:27 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1706946687; bh=PvF+EwWrp7JXup44JQu6ssRQrUrUbuCCt5KLY27Imlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=U2lmYnlYSmycEgBJXlN2kKc9yNONiBofVvUFCrMyqJeT6IAryWYlRMtj/4oueueNT yAbm+SA4Rw6NXIk5zwAIqm3mqWITyfjGJlGZ2YZlVknWGUPvwIQJBfBdFgH+wBEwEx OrRKvCWXcZ1VEG9qm+eF/wfYqYp2g6ps8915m9QYY3Y6rA6ER4vSguUXaZrGZuswoh /QsHpEIko+2L307vGAEv779FY+f9yFUTrNzuYzz61XUJc03Yvjc3yNN4wupoUSehwL 8iCkn8evBtX+Qp1WvTN/Ituv+u6jy8T+ECHVp40ZRNXTagK5Q716Z+PVHOLs9Ztyvs iJ/ivpPL7Qx+A== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 03 Feb 2024 08:51:27 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: krzysztof.kozlowski@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH v2 2/2] nfc: hci: Save a few bytes of memory when registering a 'nfc_llc' engine Date: Sat, 3 Feb 2024 08:51:04 +0100 Message-ID: <01cafe43646575d843ce81221ef4e0cdef6df84b.1706946099.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789863458205311506 X-GMAIL-MSGID: 1789863458205311506 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 Reviewed-by: Simon Horman --- 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 480c17f372a5..ba91284f4086 100644 --- a/net/nfc/hci/llc.c +++ b/net/nfc/hci/llc.c @@ -33,7 +33,7 @@ int __init nfc_llc_init(void) static void nfc_llc_del_engine(struct nfc_llc_engine *llc_engine) { list_del(&llc_engine->entry); - kfree(llc_engine->name); + kfree_const(llc_engine->name); kfree(llc_engine); } @@ -53,7 +53,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;