From 3efe509070e3d27e6d5dbc4bf8588e9453e9b949 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 18 Mar 2011 18:11:42 +0200 Subject: UBI: check if we are in RO mode in the erase routine 'do_sync_erase()' has to check whether we are in R/O mode before erasing the PEB. This patch adds the check and while on it, adds an assertion which validates the 'pnum' argument, as well as removes a check which is always true because it has already been done few lines before. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'drivers/mtd/ubi') diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index eededf9..e347cc4 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -344,6 +344,12 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum) wait_queue_head_t wq; dbg_io("erase PEB %d", pnum); + ubi_assert(pnum >= 0 && pnum < ubi->peb_count); + + if (ubi->ro_mode) { + ubi_err("read-only mode"); + return -EROFS; + } retry: init_waitqueue_head(&wq); @@ -390,7 +396,7 @@ retry: if (err) return err; - if (ubi_dbg_is_erase_failure() && !err) { + if (ubi_dbg_is_erase_failure()) { dbg_err("cannot erase PEB %d (emulated)", pnum); return -EIO; } -- cgit v1.1 From 6e5133cc757912e7ba2bfbbfb384667707f45ec3 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Fri, 25 Mar 2011 18:48:59 +0200 Subject: UBI: do not compare array with NULL Coverity spotted that UBI debugging code tries to compare an array and NULL, which obviously makes little sense. Kill this check. Signed-off-by: Artem Bityutskiy --- drivers/mtd/ubi/vmt.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/mtd/ubi') diff --git a/drivers/mtd/ubi/vmt.c b/drivers/mtd/ubi/vmt.c index b79e0de..366eb70 100644 --- a/drivers/mtd/ubi/vmt.c +++ b/drivers/mtd/ubi/vmt.c @@ -790,11 +790,6 @@ static int paranoid_check_volume(struct ubi_device *ubi, int vol_id) goto fail; } - if (!vol->name) { - ubi_err("NULL volume name"); - goto fail; - } - n = strnlen(vol->name, vol->name_len + 1); if (n != vol->name_len) { ubi_err("bad name_len %lld", n); -- cgit v1.1 From 6bef0b67474d71e0d6484cbabcc87657a1176d8d Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 30 Mar 2011 11:27:08 +0300 Subject: UBI: do not select KALLSYMS_ALL All UBI needs is to make sure we stacktraces when UBI debugging is enabled. It is enough to select KALLSYMS for this, KALLSYMS_ALL is not necessary. And the current Kconfig line we have: select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL is just too complex to be sane and right. But this "if" part there is needed to prevent "unmet direct dependency" warnings, because KALLSYMS_ALL depends on KALLSYMS and DEBUG_KERNEL, so we cannot just select KALLSYMS_ALL. Anyway, this feels messy, and we do not seem to really need KALLSYMS_ALL, so select KALLSYMS instead. Signed-off-by: Artem Bityutskiy Acked-by: Randy Dunlap --- drivers/mtd/ubi/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/ubi') diff --git a/drivers/mtd/ubi/Kconfig b/drivers/mtd/ubi/Kconfig index 6abeb4f..4dcc752 100644 --- a/drivers/mtd/ubi/Kconfig +++ b/drivers/mtd/ubi/Kconfig @@ -56,7 +56,7 @@ config MTD_UBI_DEBUG bool "UBI debugging" depends on SYSFS select DEBUG_FS - select KALLSYMS_ALL if KALLSYMS && DEBUG_KERNEL + select KALLSYMS help This option enables UBI debugging. -- cgit v1.1