From patchwork Tue Apr 25 04:52:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lokesh Vutla X-Patchwork-Id: 754578 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wBrVg4ZhHz9s7x for ; Tue, 25 Apr 2017 14:55:07 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ti.com header.i=@ti.com header.b="QLk5J9pW"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id 45BF1C21C9C; Tue, 25 Apr 2017 04:55:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 5ED38C21C33; Tue, 25 Apr 2017 04:55:03 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id F326CC21C33; Tue, 25 Apr 2017 04:55:01 +0000 (UTC) Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by lists.denx.de (Postfix) with ESMTPS id 4BFB6C21C25 for ; Tue, 25 Apr 2017 04:55:01 +0000 (UTC) Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id v3P4swCr008659; Mon, 24 Apr 2017 23:54:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1493096098; bh=ZsqzTHCK0zXK34KzDv4dDFrzimSTNFB/OnB0cxgn0gs=; h=From:To:CC:Subject:Date; b=QLk5J9pWngnL1FDPqMuEXtSXr/EvQRnDMd2dqCidEE+RTUSfOFyeIgNDhGmpqx2b2 Om0JZ56Dl4o33EbNxByW7Z2ie7VwTR5x6tKd8yiRmdvVvoM8BMf2gGqQDaepi573Jc 7DXPyxzdRwQS1sjMi8x8BtrVUqsbBIY83unUog5w= Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3P4swFX019652; Mon, 24 Apr 2017 23:54:58 -0500 Received: from dlep33.itg.ti.com (157.170.170.75) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Mon, 24 Apr 2017 23:54:57 -0500 Received: from a0131933.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v3P4stp2022561; Mon, 24 Apr 2017 23:54:55 -0500 From: Lokesh Vutla To: , Tom Rini , Date: Tue, 25 Apr 2017 10:22:27 +0530 Message-ID: <20170425045227.19713-1-lokeshvutla@ti.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Tero Kristo , fredo@starox.org Subject: [U-Boot] [RFC PATCH] ext4: Fix comparision of unsigned expression with < 0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" In file ext4fs.c funtion ext4fs_read_file() compares an unsigned expression with < 0 like below lbaint_t blknr; blknr = read_allocated_block(&(node->inode), i); if (blknr < 0) return -1; blknr is of type ulong/uint64_t. read_allocated_block() returns long int. So comparing blknr with < 0 will always be false. Instead declare blknr as long int. Reported-by: Sunita Nadampalli Signed-off-by: Lokesh Vutla --- fs/ext4/ext4fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ext4/ext4fs.c b/fs/ext4/ext4fs.c index 7187dcfb05..081509dbb4 100644 --- a/fs/ext4/ext4fs.c +++ b/fs/ext4/ext4fs.c @@ -71,7 +71,7 @@ int ext4fs_read_file(struct ext2fs_node *node, loff_t pos, blockcnt = lldiv(((len + pos) + blocksize - 1), blocksize); for (i = lldiv(pos, blocksize); i < blockcnt; i++) { - lbaint_t blknr; + long int blknr; int blockoff = pos - (blocksize * i); int blockend = blocksize; int skipfirst = 0;