nds32: use get_kernel_nofault in dump_mem
Use the proper get_kernel_nofault helper to access an unsafe kernel pointer without faulting instead of playing with set_fs and get_user. Signed-off-by: Christoph Hellwig <hch@lst.de> Acked-by: Nick Hu <nickhu@andestech.com> Acked-by: Greentime Hu <green.hu@gmail.com> Signed-off-by: Greentime Hu <green.hu@gmail.com>
This commit is contained in:
Родитель
9d63fecfcb
Коммит
fa2f478a34
|
@ -25,17 +25,8 @@ extern void show_pte(struct mm_struct *mm, unsigned long addr);
|
|||
void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
|
||||
{
|
||||
unsigned long first;
|
||||
mm_segment_t fs;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* We need to switch to kernel mode so that we can use __get_user
|
||||
* to safely read from kernel space. Note that we now dump the
|
||||
* code first, just in case the backtrace kills us.
|
||||
*/
|
||||
fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
|
||||
pr_emerg("%s(0x%08lx to 0x%08lx)\n", lvl, bottom, top);
|
||||
|
||||
for (first = bottom & ~31; first < top; first += 32) {
|
||||
|
@ -48,7 +39,9 @@ void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
|
|||
for (p = first, i = 0; i < 8 && p < top; i++, p += 4) {
|
||||
if (p >= bottom && p < top) {
|
||||
unsigned long val;
|
||||
if (__get_user(val, (unsigned long *)p) == 0)
|
||||
|
||||
if (get_kernel_nofault(val,
|
||||
(unsigned long *)p) == 0)
|
||||
sprintf(str + i * 9, " %08lx", val);
|
||||
else
|
||||
sprintf(str + i * 9, " ????????");
|
||||
|
@ -56,8 +49,6 @@ void dump_mem(const char *lvl, unsigned long bottom, unsigned long top)
|
|||
}
|
||||
pr_emerg("%s%04lx:%s\n", lvl, first & 0xffff, str);
|
||||
}
|
||||
|
||||
set_fs(fs);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dump_mem);
|
||||
|
|
Загрузка…
Ссылка в новой задаче