lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 20 Mar 2015 11:45:27 +0000
From:	Liu Sha <sz_liusha@...ctratech.com>
To:	<akpm@...ux-foundation.org>
CC:	<linux-kernel@...r.kernel.org>, <rednoax@...il.com>
Subject: [PATCH] lib/idr.c: remove duplicate bound checking in sub_alloc

The INT_MAX bound checking in sub_alloc checks two conditions to see
whether the signed integer "id" is beyond INT_MAX:

		if ((id >= MAX_IDR_BIT) || (id < 0))
			return -ENOSPC;

These two conditions are actually the same for "int" variable so one
of them can be removed. If the above snippet is compiled with -Os option
of gcc, only "id < 0" will remain in disassembly code.

Signed-off-by: Liu Sha <sz_liusha@...ctratech.com>
---
 lib/idr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/idr.c b/lib/idr.c
index 5335c43..df545ad 100644
--- a/lib/idr.c
+++ b/lib/idr.c
@@ -262,7 +262,7 @@ static int sub_alloc(struct idr *idp, int *starting_id, struct idr_layer **pa,
 			sh = IDR_BITS*l;
 			id = ((id >> sh) ^ n ^ m) << sh;
 		}
-		if ((id >= MAX_IDR_BIT) || (id < 0))
+		if (id >= MAX_IDR_BIT)
 			return -ENOSPC;
 		if (l == 0)
 			break;
-- 
2.1.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ