diff options
author | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-12-22 12:07:34 +0000 |
---|---|---|
committer | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-12-22 16:46:44 +0100 |
commit | 198e79f0e8f0b24c1e36ab6032d348f40de20262 (patch) | |
tree | d8dd6411978560fd0b6832761b085ac431253389 /compat/backport-4.0.c | |
parent | c8beff5117bd4614be26bf28e97b885e8af42a67 (diff) |
backports: bluetooth: Support 4.9 kernelsColibri-iMX7_LXDE-Image_2.8b3.111-20180627Colibri-iMX7_LXDE-Image_2.8b2.97-20180331Colibri-iMX7_LXDE-Image_2.8b1.64-20171229Colibri-iMX6_LXDE-Image_2.8b3.111-20180627Colibri-iMX6_LXDE-Image_2.8b2.97-20180331Colibri-iMX6_LXDE-Image_2.8b1.64-20171229Colibri-iMX6ULL_LXDE-Image_2.8b3.111-20180627Colibri-iMX6ULL_LXDE-Image_2.8b2.97-20180331Colibri-iMX6ULL_LXDE-Image_2.8b1.64-20171229Colibri-VF_LXDE-Image_2.8b3.111-20180626Colibri-VF_LXDE-Image_2.8b2.97-20180331Colibri-VF_LXDE-Image_2.8b1.64-20171229Colibri-T30_LXDE-Image_2.8b3.111-20180627Colibri-T30_LXDE-Image_2.8b2.97-20180331Colibri-T30_LXDE-Image_2.8b1.64-20171229Colibri-T20_LXDE-Image_2.8b3.111-20180626Colibri-T20_LXDE-Image_2.8b2.97-20180331Colibri-T20_LXDE-Image_2.8b1.64-20171229Apalis-iMX6_LXDE-Image_2.8b3.111-20180626Apalis-iMX6_LXDE-Image_2.8b2.97-20180331Apalis-iMX6_LXDE-Image_2.8b1.64-20171229Apalis-TK1_LXDE-Image_2.8b3.111-20180626Apalis-TK1_LXDE-Image_2.8b2.97-20180331Apalis-TK1_LXDE-Image_2.8b1.64-20171229Apalis-TK1-Mainline_LXDE-Image_2.8b3.111-20180627Apalis-TK1-Mainline_LXDE-Image_2.8b2.97-20180331Apalis-TK1-Mainline_LXDE-Image_2.8b1.64-20171229Apalis-T30_LXDE-Image_2.8b3.111-20180626Apalis-T30_LXDE-Image_2.8b2.97-20180331Apalis-T30_LXDE-Image_2.8b1.64-20171229toradex-4.14
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'compat/backport-4.0.c')
-rw-r--r-- | compat/backport-4.0.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/compat/backport-4.0.c b/compat/backport-4.0.c index eb95082..7f86c69 100644 --- a/compat/backport-4.0.c +++ b/compat/backport-4.0.c @@ -17,6 +17,7 @@ #include <linux/trace_seq.h> #include <linux/ftrace_event.h> #include <asm/unaligned.h> +#include <linux/slab.h> static __always_inline long __get_user_pages_locked(struct task_struct *tsk, struct mm_struct *mm, @@ -375,3 +376,35 @@ ftrace_print_array_seq(struct trace_seq *p, const void *buf, int buf_len, return ret; } EXPORT_SYMBOL(ftrace_print_array_seq); + +/** + * kfree_const - conditionally free memory + * @x: pointer to the memory + * + * Function calls kfree only if @x is not in .rodata section. + */ +void kfree_const(const void *x) +{ + /* if (!is_kernel_rodata((unsigned long)x)) */ + kfree(x); +} +EXPORT_SYMBOL(kfree_const); + +/* +* kstrdup_const - conditionally duplicate an existing const string +* @s: the string to duplicate +* @gfp: the GFP mask used in the kmalloc() call when allocating memory +* +* Function returns source string if it is in .rodata section otherwise it +* fallbacks to kstrdup. +* Strings allocated by kstrdup_const should be freed by 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); |