* [PATCH] mtd-utils: nanddump: fix writing big images on 32bit machines
@ 2022-04-25 12:35 Sascha Hauer
0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2022-04-25 12:35 UTC (permalink / raw)
To: linux-mtd; +Cc: Richard Weinberger, David Oberhollenzer, Sascha Hauer
When writing a full 4GiB NAND to a file end_addr becomes 0x100000000.
With that writing out the first page to the file doesn't happen
because size_left is calculated to 0x100000000 - 0 = 0x100000000
which is then truncated to 32bit and becomes zero. Fix this by
using an appropriate 64bit type for size_left.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
nand-utils/nanddump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
index d7fc320..47539f5 100644
--- a/nand-utils/nanddump.c
+++ b/nand-utils/nanddump.c
@@ -499,7 +499,7 @@ int main(int argc, char * const argv[])
}
} else {
/* Write requested length if oob is omitted */
- size_t size_left = end_addr - ofs;
+ long long size_left = end_addr - ofs;
if (omitoob && (size_left < bs))
err = ofd_write(ofd, readbuf, size_left);
else
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd-utils: nanddump: fix writing big images on 32bit machines
2022-06-08 7:51 Sascha Hauer
@ 2022-06-08 7:56 ` David Oberhollenzer
0 siblings, 0 replies; 3+ messages in thread
From: David Oberhollenzer @ 2022-06-08 7:56 UTC (permalink / raw)
To: Sascha Hauer, linux-mtd; +Cc: Richard Weinberger
Applied to mtd-utils.git master
Thanks,
David
On 6/8/22 09:51, Sascha Hauer wrote:
> When writing a full 4GiB NAND to a file end_addr becomes 0x100000000.
> With that writing out the first page to the file doesn't happen
> because size_left is calculated to 0x100000000 - 0 = 0x100000000
> which is then truncated to 32bit and becomes zero. Fix this by
> using an appropriate 64bit type for size_left.
>
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
> ---
> nand-utils/nanddump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
> index d7fc320..47539f5 100644
> --- a/nand-utils/nanddump.c
> +++ b/nand-utils/nanddump.c
> @@ -499,7 +499,7 @@ int main(int argc, char * const argv[])
> }
> } else {
> /* Write requested length if oob is omitted */
> - size_t size_left = end_addr - ofs;
> + long long size_left = end_addr - ofs;
> if (omitoob && (size_left < bs))
> err = ofd_write(ofd, readbuf, size_left);
> else
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] mtd-utils: nanddump: fix writing big images on 32bit machines
@ 2022-06-08 7:51 Sascha Hauer
2022-06-08 7:56 ` David Oberhollenzer
0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2022-06-08 7:51 UTC (permalink / raw)
To: linux-mtd; +Cc: Richard Weinberger, David Oberhollenzer, Sascha Hauer
When writing a full 4GiB NAND to a file end_addr becomes 0x100000000.
With that writing out the first page to the file doesn't happen
because size_left is calculated to 0x100000000 - 0 = 0x100000000
which is then truncated to 32bit and becomes zero. Fix this by
using an appropriate 64bit type for size_left.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
nand-utils/nanddump.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nand-utils/nanddump.c b/nand-utils/nanddump.c
index d7fc320..47539f5 100644
--- a/nand-utils/nanddump.c
+++ b/nand-utils/nanddump.c
@@ -499,7 +499,7 @@ int main(int argc, char * const argv[])
}
} else {
/* Write requested length if oob is omitted */
- size_t size_left = end_addr - ofs;
+ long long size_left = end_addr - ofs;
if (omitoob && (size_left < bs))
err = ofd_write(ofd, readbuf, size_left);
else
--
2.30.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-06-08 7:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-25 12:35 [PATCH] mtd-utils: nanddump: fix writing big images on 32bit machines Sascha Hauer
2022-06-08 7:51 Sascha Hauer
2022-06-08 7:56 ` David Oberhollenzer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).