diff mbox series

mtd: mtdpart: use uint64_t instead of int for cur_off

Message ID 20200713124002.20882-1-martin.kaistra@linutronix.de
State Accepted
Commit 892d4617357db355bf847ca37dd76cf946727ec2
Delegated to: Tom Rini
Headers show
Series mtd: mtdpart: use uint64_t instead of int for cur_off | expand

Commit Message

Martin Kaistra July 13, 2020, 12:40 p.m. UTC
The types of "offset" and "size" of "struct mtd_partition" are uint64_t,
while mtd_parse_partitions() uses int to work with these values. When
the offset reaches 2GB, it is interpreted as a negative value, which
leads to error messages like

mtd: partition "<partition name>" is out of reach -- disabled

eg. when using the "ubi part" command.

Fix this by using uint64_t for cur_off and cur_sz.

Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
---
 drivers/mtd/mtdpart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Heiko Schocher July 17, 2020, 4 a.m. UTC | #1
Hello Martin,

Am 13.07.2020 um 14:40 schrieb Martin Kaistra:
> The types of "offset" and "size" of "struct mtd_partition" are uint64_t,
> while mtd_parse_partitions() uses int to work with these values. When
> the offset reaches 2GB, it is interpreted as a negative value, which
> leads to error messages like
> 
> mtd: partition "<partition name>" is out of reach -- disabled
> 
> eg. when using the "ubi part" command.
> 
> Fix this by using uint64_t for cur_off and cur_sz.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
>   drivers/mtd/mtdpart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
Tom Rini July 17, 2020, 8:58 p.m. UTC | #2
On Mon, Jul 13, 2020 at 02:40:02PM +0200, Martin Kaistra wrote:

> The types of "offset" and "size" of "struct mtd_partition" are uint64_t,
> while mtd_parse_partitions() uses int to work with these values. When
> the offset reaches 2GB, it is interpreted as a negative value, which
> leads to error messages like
> 
> mtd: partition "<partition name>" is out of reach -- disabled
> 
> eg. when using the "ubi part" command.
> 
> Fix this by using uint64_t for cur_off and cur_sz.
> 
> Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index d1f6029b2bf..d064ac30480 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -207,7 +207,7 @@  int mtd_parse_partitions(struct mtd_info *parent, const char **_mtdparts,
 {
 	struct mtd_partition partition = {}, *parts;
 	const char *mtdparts = *_mtdparts;
-	int cur_off = 0, cur_sz = 0;
+	uint64_t cur_off = 0, cur_sz = 0;
 	int nparts = 0;
 	int ret, idx;
 	u64 sz;