From patchwork Wed Nov 7 01:33:12 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [U-Boot] part: check each variable for capability calculation Date: Tue, 06 Nov 2012 15:33:12 -0000 From: Jerry Huang X-Patchwork-Id: 197611 Message-Id: <1352251992-7387-1-git-send-email-Chang-Ming.Huang@freescale.com> To: Cc: Jerry Huang From: Jerry Huang 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 --- disk/part.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk/part.c b/disk/part.c index 4646f68..7bdc90e 100644 --- a/disk/part.c +++ b/disk/part.c @@ -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;