mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
Use map_sysmem when accessing memory in setexpr
The setexpr command used to segfault when accessing memory in sandbox. The pointer accesses should be mapped. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com> Cc: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
9597494ebf
commit
2068cea173
1 changed files with 23 additions and 9 deletions
|
@ -12,23 +12,37 @@
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <mapmem.h>
|
||||||
|
|
||||||
static ulong get_arg(char *s, int w)
|
static ulong get_arg(char *s, int w)
|
||||||
{
|
{
|
||||||
ulong *p;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* if the parameter starts with a '*' then assume
|
* If the parameter starts with a '*' then assume it is a pointer to
|
||||||
* it is a pointer to the value we want
|
* the value we want.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (s[0] == '*') {
|
if (s[0] == '*') {
|
||||||
p = (ulong *)simple_strtoul(&s[1], NULL, 16);
|
ulong *p;
|
||||||
|
ulong addr;
|
||||||
|
ulong val;
|
||||||
|
|
||||||
|
addr = simple_strtoul(&s[1], NULL, 16);
|
||||||
switch (w) {
|
switch (w) {
|
||||||
case 1: return((ulong)(*(uchar *)p));
|
case 1:
|
||||||
case 2: return((ulong)(*(ushort *)p));
|
p = map_sysmem(addr, sizeof(uchar));
|
||||||
|
val = (ulong)*(uchar *)p;
|
||||||
|
unmap_sysmem(p);
|
||||||
|
return val;
|
||||||
|
case 2:
|
||||||
|
p = map_sysmem(addr, sizeof(ushort));
|
||||||
|
val = (ulong)*(ushort *)p;
|
||||||
|
unmap_sysmem(p);
|
||||||
|
return val;
|
||||||
case 4:
|
case 4:
|
||||||
default: return(*p);
|
default:
|
||||||
|
p = map_sysmem(addr, sizeof(ulong));
|
||||||
|
val = *p;
|
||||||
|
unmap_sysmem(p);
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return simple_strtoul(s, NULL, 16);
|
return simple_strtoul(s, NULL, 16);
|
||||||
|
|
Loading…
Reference in a new issue