part: check each variable for capability calculation
authorJerry Huang <Chang-Ming.Huang@freescale.com>
Tue, 6 Nov 2012 15:33:12 +0000 (15:33 +0000)
committerTom Rini <trini@ti.com>
Thu, 6 Dec 2012 20:56:39 +0000 (13:56 -0700)
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>
disk/part.c

index 4646f682d2c8b6c7f05bf0dc5ea9fba1c8b4f791..7bdc90eff701183934874195356c36e6d5a4ab5f 100644 (file)
@@ -199,7 +199,7 @@ void dev_print (block_dev_desc_t *dev_desc)
                break;
        }
        puts ("\n");
-       if ((dev_desc->lba * dev_desc->blksz)>0L) {
+       if (dev_desc->lba > 0L && dev_desc->blksz > 0L) {
                ulong mb, mb_quot, mb_rem, gb, gb_quot, gb_rem;
                lbaint_t lba;