On Mon, 2015-01-12 at 10:18 +0100, Andrzej Hajda wrote: > The patch adds alternative version of kstrdup which returns pointer > to constant char array. The function checks if input string is in > persistent and read-only memory section, if yes it returns the input string, > otherwise it fallbacks to kstrdup. > kstrdup_const is accompanied by kfree_const performing conditional memory > deallocation of the string. trivia: > diff --git a/mm/util.c b/mm/util.c [] > +void kfree_const(const void *x) > +{ > + if (!is_kernel_rodata((unsigned long)x)) > + kfree(x); > +} > +EXPORT_SYMBOL(kfree_const); [] > +const char *kstrdup_const(const char *s, gfp_t gfp) > +{ > + if (is_kernel_rodata((unsigned long)s)) > + return s; > + > + return kstrdup(s, gfp); > +} > +EXPORT_SYMBOL(kstrdup_const); I think it'd be nicer if these used the same form even if it's a vertical line or 2 longer void kfree_const(const void *x) { if (is_kernel_rodata((unsigned long)x)) return; kfree(x); } -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@xxxxxxxxx. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@xxxxxxxxx"> email@xxxxxxxxx </a>