[smatch stuff] mtd/ubi/gluebi: signedness warnings

Artem Bityutskiy dedekind1 at gmail.com
Fri Oct 14 05:42:18 EDT 2011


On Mon, 2011-10-10 at 12:28 +0300, Dan Carpenter wrote:
> Smatch complains about some to the checks in gluebi.c
> 
> drivers/mtd/ubi/gluebi.c +177 gluebi_read(6) warn: unsigned 'len' is never less than zero.
> drivers/mtd/ubi/gluebi.c +221 gluebi_write(6) warn: unsigned 'len' is never less than zero.
> drivers/mtd/ubi/gluebi.c +270 gluebi_erase(7) warn: unsigned 'instr->len' is never less than zero.
> 
> I think probably these checks can just be removed?  Can these things
> wrap if we passed a huge value for instr->len?
> 
>    270          if (instr->len < 0 || instr->addr + instr->len > mtd->size)
>    271                  return -EINVAL;
> 
> I don't know enough about how these are called to say.

Dan, smatch is right, that check is stupid. And yes, things can wrap. So
I guess this need 2 patches - one removes the "< 0" check, the other
prevents wrapping. And the code is a bit messy WRT int vs size_t.

I guess we could fix the warnings with the following patch, but wrapping
would need a separate fix.





More information about the linux-mtd mailing list