From 7501798fab7f1ec17e0baaa44d611e93c3f2727a Mon Sep 17 00:00:00 2001 From: Kolja Dummann Date: Tue, 28 Dec 2010 23:54:29 +0100 Subject: [PATCH] Fix nullpointer when recovery.fstab does not define a "misc" partition Change-Id: I57437e3c637a1c619d254a3fc025db19ffe53c10 --- bootloader.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/bootloader.c b/bootloader.c index b690c55..f3dc268 100644 --- a/bootloader.c +++ b/bootloader.c @@ -30,23 +30,33 @@ static int set_bootloader_message_block(const struct bootloader_message *in, con int get_bootloader_message(struct bootloader_message *out) { Volume* v = volume_for_path("/misc"); - if (strcmp(v->fs_type, "mtd") == 0) { - return get_bootloader_message_mtd(out, v); - } else if (strcmp(v->fs_type, "emmc") == 0) { - return get_bootloader_message_block(out, v); + if(v) + { + if (strcmp(v->fs_type, "mtd") == 0) { + return get_bootloader_message_mtd(out, v); + } else if (strcmp(v->fs_type, "emmc") == 0) { + return get_bootloader_message_block(out, v); + } + LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + return -1; } - LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + LOGE("no misc partition\n"); return -1; } int set_bootloader_message(const struct bootloader_message *in) { Volume* v = volume_for_path("/misc"); - if (strcmp(v->fs_type, "mtd") == 0) { - return set_bootloader_message_mtd(in, v); - } else if (strcmp(v->fs_type, "emmc") == 0) { - return set_bootloader_message_block(in, v); + if(v) + { + if (strcmp(v->fs_type, "mtd") == 0) { + return set_bootloader_message_mtd(in, v); + } else if (strcmp(v->fs_type, "emmc") == 0) { + return set_bootloader_message_block(in, v); + } + LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + return -1; } - LOGE("unknown misc partition fs_type \"%s\"\n", v->fs_type); + LOGE("no misc partition\n"); return -1; }