Message ID | 1345355849-8992-1-git-send-email-shijie8@gmail.com |
---|---|
State | New, archived |
Headers | show |
On Sun, 2012-08-19 at 01:57 -0400, Huang Shijie wrote: > 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@gmail.com> 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. > @@ -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.
On Fri, Aug 24, 2012 at 12:06 PM, Artem Bityutskiy <dedekind1@gmail.com> wrote: > So you may also just add > > if (!mtd_id) > return 0 > > at the beginning? yes. Your code is better then mine. Huang Shijie
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++) {
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@gmail.com> --- drivers/mtd/cmdlinepart.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)