Skip to content

Commit

Permalink
mm: move is_kernel_rodata() to asm-generic/sections.h
Browse files Browse the repository at this point in the history
Export this routine so that we can use it later in devm_kstrdup_const()
and devm_kfree().

Signed-off-by: Bartosz Golaszewski <[email protected]>
Reviewed-by: Bjorn Andersson <[email protected]>
Acked-by: Mike Rapoport <[email protected]>
Acked-by: Rasmus Villemoes <[email protected]>
Reviewed-by: Geert Uytterhoeven <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
brgl authored and gregkh committed Oct 16, 2018
1 parent 0571967 commit 59c3f82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 14 additions & 0 deletions include/asm-generic/sections.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,18 @@ static inline bool init_section_intersects(void *virt, size_t size)
return memory_intersects(__init_begin, __init_end, virt, size);
}

/**
* is_kernel_rodata - checks if the pointer address is located in the
* .rodata section
*
* @addr: address to check
*
* Returns: true if the address is located in .rodata, false otherwise.
*/
static inline bool is_kernel_rodata(unsigned long addr)
{
return addr >= (unsigned long)__start_rodata &&
addr < (unsigned long)__end_rodata;
}

#endif /* _ASM_GENERIC_SECTIONS_H_ */
7 changes: 0 additions & 7 deletions mm/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,10 @@
#include <linux/vmalloc.h>
#include <linux/userfaultfd_k.h>

#include <asm/sections.h>
#include <linux/uaccess.h>

#include "internal.h"

static inline int is_kernel_rodata(unsigned long addr)
{
return addr >= (unsigned long)__start_rodata &&
addr < (unsigned long)__end_rodata;
}

/**
* kfree_const - conditionally free memory
* @x: pointer to the memory
Expand Down

0 comments on commit 59c3f82

Please sign in to comment.