mtd: cmdlinepart: fix the wrong check condition
PATCH 1/1 mtd: cmdlinepart: fix the wrong check condition
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.
--- drivers/mtd/cmdlinepart.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mtd/cmdlinepart.c +1 -1
@@ -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++) {
Signature · 1 line
1.7.4.4
Quoted 7 lines · Huang Shijie
If the
mtd_idis 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 <[email protected]>
I do not understand from the description what is exactly the problem with the current code, and how exactly you solve it. Please, elaborate some more by re-sending the patch with better commit message.
drivers/mtd/cmdlinepart.c static int parse_cmdline_partitions(struct mtd_info *master, · line 334
Quoted 9 lines
drivers/mtd/cmdlinepart.c +1
-1@@ -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++) {
So you may also just add
if (!mtd_id)
return 0
at the beginning?
I guess you should first try to explain what that check is trying to do, what is mtd_id and when it can be NULL. Then tell what is the problem and how you solve it.
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 6 lines · Artem Bityutskiy
So you may also just add
if (!mtd_id)
return 0at the beginning?
yes. Your code is better then mine.
Huang Shijie