summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfaqiang.zhu <faqiang.zhu@nxp.com>2020-10-14 19:50:10 +0800
committerJi Luo <ji.luo@nxp.com>2022-04-18 16:40:09 +0800
commit26964152b3d1a254cf448f86839c30d609fb62dd (patch)
tree5f536163b10f42855d47efddd90b4787d29a9cb2
parent6c9550d1406108879b786fd58f610f213d7a20ca (diff)
MA-18051 avoid overflow of in partition size calculation
If a partition is not less than 4GB, to avoid the overflow issue when calculate the partition size in bytes, change the value of partition length in block size to the type of "unsigned long". Change-Id: Ifa4ddb5169fcb02822ef152a6c70d01b5d3cf50d Signed-off-by: faqiang.zhu <faqiang.zhu@nxp.com> (cherry picked from commit c4e9be08d90ca59531542c97bd8fe16eab2ab099) (cherry picked from commit 6c1471828256f5c95d3043099fcc00906726fdd3) (cherry picked from commit 900872464c2d8cb1862ac1d2a413d631bce64213)
-rw-r--r--drivers/fastboot/fb_fsl/fb_fsl_dev.c2
-rw-r--r--drivers/fastboot/fb_fsl/fb_fsl_partitions.c2
-rw-r--r--include/fb_fsl.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/fastboot/fb_fsl/fb_fsl_dev.c b/drivers/fastboot/fb_fsl/fb_fsl_dev.c
index 84b2e2366f6..0ac2de5d72a 100644
--- a/drivers/fastboot/fb_fsl/fb_fsl_dev.c
+++ b/drivers/fastboot/fb_fsl/fb_fsl_dev.c
@@ -395,7 +395,7 @@ static void process_flash_sf(const char *cmdbuf, void *download_buffer,
return;
}
/* Erase */
- sprintf(sf_command, "sf erase 0x%x 0x%x", ptn->start * blksz, /*start*/
+ sprintf(sf_command, "sf erase 0x%x 0x%lx", ptn->start * blksz, /*start*/
ptn->length * blksz /*size*/);
ret = run_command(sf_command, 0);
if (ret) {
diff --git a/drivers/fastboot/fb_fsl/fb_fsl_partitions.c b/drivers/fastboot/fb_fsl/fb_fsl_partitions.c
index 2ba58df2c4d..59027c07559 100644
--- a/drivers/fastboot/fb_fsl/fb_fsl_partitions.c
+++ b/drivers/fastboot/fb_fsl/fb_fsl_partitions.c
@@ -280,7 +280,7 @@ void fastboot_flash_dump_ptn(void)
unsigned int n;
for (n = 0; n < g_pcount; n++) {
struct fastboot_ptentry *ptn = g_ptable + n;
- printf("idx %d, ptn %d name='%s' start=%d len=%d\n",
+ printf("idx %d, ptn %d name='%s' start=%d len=%ld\n",
n, ptn->partition_index, ptn->name, ptn->start, ptn->length);
}
}
diff --git a/include/fb_fsl.h b/include/fb_fsl.h
index b6308b88d54..3c551afcb80 100644
--- a/include/fb_fsl.h
+++ b/include/fb_fsl.h
@@ -167,7 +167,7 @@ struct fastboot_ptentry {
/* The start wrt the nand part, must be multiple of nand block size */
unsigned int start;
/* The length of the partition, must be multiple of nand block size */
- unsigned int length;
+ unsigned long length;
/* Controls the details of how operations are done on the partition
See the FASTBOOT_PTENTRY_FLAGS_*'s defined below */
unsigned int flags;