diff mbox

[U-Boot,v2,06/22] Correct map_sysmem() logic in do_mem_mw()

Message ID 1425583534-2238-7-git-send-email-sjg@chromium.org
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Simon Glass March 5, 2015, 7:25 p.m. UTC
This function does not unmap what it maps. Correct it.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

 common/cmd_mem.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Bin Meng March 9, 2015, 9:06 a.m. UTC | #1
On Fri, Mar 6, 2015 at 3:25 AM, Simon Glass <sjg@chromium.org> wrote:
> This function does not unmap what it maps. Correct it.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> Changes in v2: None
>
>  common/cmd_mem.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/common/cmd_mem.c b/common/cmd_mem.c
> index bcb3ee3..855aa57 100644
> --- a/common/cmd_mem.c
> +++ b/common/cmd_mem.c
> @@ -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;
>  }
>
> --

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Simon Glass March 20, 2015, 11:14 p.m. UTC | #2
On 9 March 2015 at 03:06, Bin Meng <bmeng.cn@gmail.com> wrote:
> On Fri, Mar 6, 2015 at 3:25 AM, Simon Glass <sjg@chromium.org> wrote:
>> This function does not unmap what it maps. Correct it.
>>
>> Signed-off-by: Simon Glass <sjg@chromium.org>
>> ---
>>
>> Changes in v2: None
>>
>>  common/cmd_mem.c | 7 ++++---
>>  1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/common/cmd_mem.c b/common/cmd_mem.c
>> index bcb3ee3..855aa57 100644
>> --- a/common/cmd_mem.c
>> +++ b/common/cmd_mem.c
>> @@ -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;
>>  }
>>
>> --
>
> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Applied to u-boot-dm/next.
diff mbox

Patch

diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index bcb3ee3..855aa57 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -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;
 }