On Tue, Aug 11, 2026 at 3:13 PM Andy Shevchenko <[email protected]> wrote: > > __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 <[email protected]> > Link: > https://lore.kernel.org/r/CAGXv+5HGZwAKpGpyV4=qhfg7ybqpx-syc1gma2qad_tzw_r...@mail.gmail.com > Signed-off-by: Andy Shevchenko <[email protected]> > --- > 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)) > +
Matches what we already have for kfree(), so Reviewed-by: Chen-Yu Tsai <[email protected]> > 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 >

