mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Kees Cook <kees@kernel.org>, Andy Shevchenko <andy@kernel.org>,
	Chen-Yu Tsai <wenst@chromium.org>
Subject: [PATCH v1 1/1] string: Introduce __free(kfree_const)
Date: Tue, 11 Aug 2026 09:13:17 +0200	[thread overview]
Message-ID: <20260811071319.1352016-1-andriy.shevchenko@linux.intel.com> (raw)

__free(kfree_const) may be used in the cases when one part of the code
relies on the constant string literals, while the other uses a heap
(via kasprintf(), for example).

Requested-by: Chen-Yu Tsai <wenst@chromium.org>
Link: https://lore.kernel.org/r/CAGXv+5HGZwAKpGpyV4=QHfg7yBQPx-syc1Gma2qad_tzW_RLog@mail.gmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/string.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 75bfc194ad20..6f3501b56c11 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -294,8 +294,11 @@ static inline bool mem_is_zero(const void *s, size_t n)
 	return !memchr_inv(s, 0, n);
 }
 
+/* mm/util.c */
 extern void kfree_const(const void *x);
 
+DEFINE_FREE(kfree_const, void *, if (!IS_ERR_OR_NULL(_T)) kfree_const(_T))
+
 extern char *kstrdup(const char *s, gfp_t gfp) __malloc;
 extern const char *kstrdup_const(const char *s, gfp_t gfp);
 extern char *kstrndup(const char *s, size_t len, gfp_t gfp);
-- 
2.50.1


             reply	other threads:[~2026-08-11  7:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  7:13 Andy Shevchenko [this message]
2026-08-11 10:42 ` Chen-Yu Tsai
2026-08-11 10:53   ` Andy Shevchenko
2026-08-11 10:58     ` Chen-Yu Tsai
2026-08-11 11:39       ` Chen-Yu Tsai

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=20260811071319.1352016-1-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=wenst@chromium.org \
    /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: link
Be 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

all inboxes | Powered by JetHome®