From patchwork Sun Aug 19 05:57:29 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: mtd: cmdlinepart: fix the wrong check condition Date: Sat, 18 Aug 2012 19:57:29 -0000 From: Huang Shijie X-Patchwork-Id: 178481 Message-Id: <1345355849-8992-1-git-send-email-shijie8@gmail.com> To: dwmw2@infradead.org Cc: Huang Shijie , linux-mtd@lists.infradead.org, dedekind1@gmail.com If the mtd_id is NULL, the check condition will be true. So the cmdlinepart may parses out several mtd partitions. This is obviously wrong. Just fix it. Signed-off-by: Huang Shijie --- drivers/mtd/cmdlinepart.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index fc960a3..330b25f 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c @@ -328,7 +328,7 @@ static int parse_cmdline_partitions(struct mtd_info *master, for(part = partitions; part; part = part->next) { - if ((!mtd_id) || (!strcmp(part->mtd_id, mtd_id))) + if (mtd_id && (!strcmp(part->mtd_id, mtd_id))) { for(i = 0, offset = 0; i < part->num_parts; i++) {