Skip to contentSkip to conversation

mtd: mtdpart: use uint64_t instead of int for cur_off

PATCH New Martin Kaistra 3 participants 3 messages Jul 13, 2020 – Jul 17, 2020 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: mtdpart: use uint64_t instead of int for cur_off

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.

---
 drivers/mtd/mtdpart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/mtdpart.c +1 -1
index d1f6029b2bf..d064ac30480 100644
@@ -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;
Signature · 1 line
2.20.1
#1 lore raw

PATCH 1/1 mtd: mtdpart: use uint64_t instead of int for cur_off

Hello Martin,

Am 13.07.2020 um 14:40 schrieb Martin Kaistra:

Quoted 9 lines

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.

Quoted 7 lines

Fix this by using uint64_t for cur_off and cur_sz.

---
  drivers/mtd/mtdpart.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

bye,
Heiko

Signature · 3 lines
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de
#2 lore raw

PATCH 1/1 mtd: mtdpart: use uint64_t instead of int for cur_off

In reply to Martin Kaistra
Quoted 7 lines · 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

Quoted 7 lines

eg. when using the "ubi part" command.

Fix this by using uint64_t for cur_off and cur_sz.

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200717/7636120c/attachment.sig>