summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/parsers
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2022-10-25 17:34:24 +0200
committerMiquel Raynal <miquel.raynal@bootlin.com>2022-11-07 17:11:33 +0100
commit6c0a15a3dc6b45156c5b9568c8308e3f0d802af0 (patch)
tree277fd664f5fae07897bb5627c17e99ce64617503 /drivers/mtd/parsers
parentmtd: parsers: add TP-Link SafeLoader partitions table parser (diff)
downloadlinux-6c0a15a3dc6b45156c5b9568c8308e3f0d802af0.tar.xz
linux-6c0a15a3dc6b45156c5b9568c8308e3f0d802af0.zip
mtd: parsers: tplink_safeloader: fix uninitialized variable bug
On 64 bit systems, the highest 32 bits of the "offset" variable are not initialized. Also the existing code is not endian safe (it will fail on big endian systems). Change the type of "offset" to a u32. Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Rafał Miłecki <rafal@milecki.pl> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/linux-mtd/Y1gCALFWXYYwqV1P@kili
Diffstat (limited to 'drivers/mtd/parsers')
-rw-r--r--drivers/mtd/parsers/tplink_safeloader.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
index 23584a477391..f601e7bd8627 100644
--- a/drivers/mtd/parsers/tplink_safeloader.c
+++ b/drivers/mtd/parsers/tplink_safeloader.c
@@ -23,8 +23,8 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
struct safeloader_cmn_header hdr;
struct device_node *np;
size_t bytes_read;
- size_t offset;
size_t size;
+ u32 offset;
char *buf;
int err;
@@ -34,14 +34,14 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
else
np = of_get_child_by_name(np, "partitions");
- if (of_property_read_u32(np, "partitions-table-offset", (u32 *)&offset)) {
+ if (of_property_read_u32(np, "partitions-table-offset", &offset)) {
pr_err("Failed to get partitions table offset\n");
goto err_put;
}
err = mtd_read(mtd, offset, sizeof(hdr), &bytes_read, (uint8_t *)&hdr);
if (err && !mtd_is_bitflip(err)) {
- pr_err("Failed to read from %s at 0x%zx\n", mtd->name, offset);
+ pr_err("Failed to read from %s at 0x%x\n", mtd->name, offset);
goto err_put;
}