X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fopenwrt.git;a=blobdiff_plain;f=target%2Flinux%2Fgeneric%2Fpending-4.9%2F490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch;h=168cfe50ee4290f6df6f025167624de9d2c3bdfd;hp=8b923d17d6342e8fb2bb6b0aa5c041b3ccf5eeba;hb=fc45ae44613b41f7328e81d0999f609dd7e81482;hpb=0ac91d82ed4d077150db902eb12d383c2be44fb2 diff --git a/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch b/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch index 8b923d17d6..168cfe50ee 100644 --- a/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch +++ b/target/linux/generic/pending-4.9/490-ubi-auto-attach-mtd-device-named-ubi-or-data-on-boot.patch @@ -8,7 +8,7 @@ Signed-off-by: Daniel Golle --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c -@@ -1226,6 +1226,68 @@ static struct mtd_info * __init open_mtd +@@ -1226,6 +1226,73 @@ static struct mtd_info * __init open_mtd return mtd; } @@ -44,10 +44,15 @@ Signed-off-by: Daniel Golle + } + } + -+ /* check for a valid ubi magic if read from flash was successful */ ++ /* check if the read from flash was successful */ + err = mtd_read(mtd, offset, 4, &len, (void *) magic); -+ if ((!err || mtd_is_bitflip(err)) && -+ len == 4 && strncmp(magic, "UBI#", 4)) { ++ if ((err && !mtd_is_bitflip(err)) || len != 4) { ++ pr_err("UBI error: unable to read from mtd%d\n", mtd->index); ++ goto cleanup; ++ } ++ ++ /* check for a valid ubi magic */ ++ if (strncmp(magic, "UBI#", 4)) { + pr_err("UBI error: no valid UBI magic found inside mtd%d\n", mtd->index); + goto cleanup; + } @@ -77,7 +82,7 @@ Signed-off-by: Daniel Golle static int __init ubi_init(void) { int err, i, k; -@@ -1309,6 +1371,12 @@ static int __init ubi_init(void) +@@ -1309,6 +1376,12 @@ static int __init ubi_init(void) } }