[PATCH] mtd: cmdlinepart: fix the wrong check condition

Huang Shijie shijie8 at gmail.com
Sun Aug 19 01:57:29 EDT 2012


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 <shijie8 at gmail.com>
---
 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++)
 			{
-- 
1.7.4.4




More information about the linux-mtd mailing list