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

Artem Bityutskiy dedekind1 at gmail.com
Fri Aug 24 12:06:27 EDT 2012


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 at 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.

-- 
Best Regards,
Artem Bityutskiy
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.infradead.org/pipermail/linux-mtd/attachments/20120824/27fc6cc7/attachment.sig>


More information about the linux-mtd mailing list