[bug reportish] UBI_MAX_ERASECOUNTER not used consistently

Artem Bityutskiy dedekind1 at gmail.com
Thu Oct 11 10:33:05 EDT 2012


On Fri, 2012-10-05 at 09:57 +0300, Dan Carpenter wrote:
> Hi Artem,
> 
> I normally audit for underflows and I had a question about this code.
> 
> mtd/ubi/attach.c
>    665  static int early_erase_peb(struct ubi_device *ubi,
>    666                             const struct ubi_attach_info *ai, int pnum, int ec)
>    667  {
>    668          int err;
>    669          struct ubi_ec_hdr *ec_hdr;
>    670  
>    671          if ((long long)ec >= UBI_MAX_ERASECOUNTER) {
> 
> Casting to long long doesn't serve any purpose.  We normally say that
> "> UBI_MAX_ERASECOUNTER" is invalid but "== UBI_MAX_ERASECOUNTER" is Ok.
> The "ec" variable is signed and negative values are missed on this
> check.

Yes, the cast is bogus. I can fix it by removing the cast, but would
like to give you a chance to send the patch so that you get the credit
being the author in the git history. Let me know what you prefer.

Thanks!

-- 
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/20121011/646f5d37/attachment.sig>


More information about the linux-mtd mailing list