Commit 33699df12cbcd9bfa609dc7fb5a0a69c029449e9

Authored by Jerry Huang
Committed by Tom Rini
1 parent e3ff797cdb

part: check each variable for capability calculation

In order to calculate the capability, we use the below expression to check:
((dev_desc->lba * dev_desc->blksz)>0L)
If the capability is greater than 4GB (e.g. 8GB = 8 * 1024 * 104 * 1024),
the result will overflow, the low 32bit may be zero.

Therefore, change to check each variable to fix this potential issue.

Signed-off-by: Jerry Huang <Chang-Ming.Huang@freescale.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -199,7 +199,7 @@
199 199 break;
200 200 }
201 201 puts ("\n");
202   - if ((dev_desc->lba * dev_desc->blksz)>0L) {
  202 + if (dev_desc->lba > 0L && dev_desc->blksz > 0L) {
203 203 ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
204 204 lbaint_t lba;
205 205