aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/mtd/mtdsplit
diff options
context:
space:
mode:
authorMathias Kresin <dev@kresin.me>2016-09-29 19:28:13 +0200
committerMathias Kresin <dev@kresin.me>2016-10-15 09:01:45 +0200
commit634d690d740ad2e586701a393d60cc9753808193 (patch)
tree2a37a4af5af4c372cb97f0826ae953d87f5217dc /target/linux/generic/files/drivers/mtd/mtdsplit
parent35073d47bb91fc0066a08c85c9206a6338a19b7e (diff)
downloadupstream-634d690d740ad2e586701a393d60cc9753808193.tar.gz
upstream-634d690d740ad2e586701a393d60cc9753808193.tar.bz2
upstream-634d690d740ad2e586701a393d60cc9753808193.zip
kernel: mtdsplit_uimage: fix Edimax parser
According to the author the code was added to in preparation for adding support for a new board. The patch for the board was never send and the code never really tested. The edimax header starting with the edimax magic is put in front of the uImage header. There is no special uImage header used. Means, default magic and the type field is set to kernel as usual. Signed-off-by: Mathias Kresin <dev@kresin.me> edimax parser fix
Diffstat (limited to 'target/linux/generic/files/drivers/mtd/mtdsplit')
-rw-r--r--target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
index 3ddb71bfa7..26cb66ac7f 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit_uimage.c
@@ -310,27 +310,21 @@ static struct mtd_part_parser uimage_netgear_parser = {
static ssize_t uimage_find_edimax(u_char *buf, size_t len)
{
- struct uimage_header *header;
+ u32 *magic;
- if (len < FW_EDIMAX_OFFSET + sizeof(*header)) {
+ if (len < FW_EDIMAX_OFFSET + sizeof(struct uimage_header)) {
pr_err("Buffer too small for checking Edimax header\n");
return -ENOSPC;
}
- header = (struct uimage_header *)(buf + FW_EDIMAX_OFFSET);
-
- switch be32_to_cpu(header->ih_magic) {
- case FW_MAGIC_EDIMAX:
- break;
- default:
+ magic = (u32 *)buf;
+ if (be32_to_cpu(*magic) != FW_MAGIC_EDIMAX)
return -EINVAL;
- }
- if (header->ih_os != IH_OS_LINUX ||
- header->ih_type != IH_TYPE_FILESYSTEM)
- return -EINVAL;
+ if (!uimage_verify_default(buf + FW_EDIMAX_OFFSET, len))
+ return FW_EDIMAX_OFFSET;
- return FW_EDIMAX_OFFSET;
+ return -EINVAL;
}
static int