Skip to content
Snippets Groups Projects
Commit cc5e196e authored by Simon Glass's avatar Simon Glass
Browse files

Correct map_sysmem() logic in do_mem_mw()


This function does not unmap what it maps. Correct it.

Signed-off-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarBin Meng <bmeng.cn@gmail.com>
parent 161d2e4e
No related branches found
No related tags found
No related merge requests found
......@@ -165,7 +165,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
#endif
ulong addr, count;
int size;
void *buf;
void *buf, *start;
ulong bytes;
if ((argc < 3) || (argc > 4))
......@@ -197,7 +197,8 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
}
bytes = size * count;
buf = map_sysmem(addr, bytes);
start = map_sysmem(addr, bytes);
buf = start;
while (count-- > 0) {
if (size == 4)
*((u32 *)buf) = (u32)writeval;
......@@ -211,7 +212,7 @@ static int do_mem_mw(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
*((u8 *)buf) = (u8)writeval;
buf += size;
}
unmap_sysmem(buf);
unmap_sysmem(start);
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment