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>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 25 Jul 2017 04:06:34 -0700
From:   Tonghao Zhang <xiangxia.m.yue@...il.com>
To:     netdev@...r.kernel.org
Cc:     Tonghao Zhang <xiangxia.m.yue@...il.com>,
        Zhao Qiang <qiang.zhao@....com>
Subject: [PATCH 3/3] drivers/net: Unsigned expressions cannot be lesser than zero.

Presence of comparisons 'unsigned (<|<=|>|>=) 0' often indicates
a bug, usually wrong type of variable.

When using the qe_muram_alloc to alloc memory, return an offset
into the muram area on success and (unsigned long)-ENOMEM or
-ENOSYS (if not config CONFIG_CPM and CONFIG_QUICC_ENGINE) on
failure.

Generated by: scripts/coccinelle/tests/unsigned_lesser_than_zero.cocci
Fix c19b6d24('drivers/net: support hdlc function for QE-UCC')

Cc: Zhao Qiang <qiang.zhao@....com>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@...il.com>
---
 drivers/net/wan/fsl_ucc_hdlc.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 33df764..155f044 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -192,7 +192,8 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
 	priv->ucc_pram_offset = qe_muram_alloc(sizeof(struct ucc_hdlc_param),
 				ALIGNMENT_OF_UCC_HDLC_PRAM);
 
-	if (priv->ucc_pram_offset < 0) {
+	if (priv->ucc_pram_offset == (unsigned long)-ENOMEM ||
+	    priv->ucc_pram_offset == (unsigned long)-ENOSYS) {
 		dev_err(priv->dev, "Can not allocate MURAM for hdlc parameter.\n");
 		ret = -ENOMEM;
 		goto free_tx_bd;
@@ -228,14 +229,16 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
 
 	/* Alloc riptr, tiptr */
 	riptr = qe_muram_alloc(32, 32);
-	if (riptr < 0) {
+	if (riptr == (unsigned long)-ENOMEM ||
+	    riptr == (unsigned long)-ENOSYS) {
 		dev_err(priv->dev, "Cannot allocate MURAM mem for Receive internal temp data pointer\n");
 		ret = -ENOMEM;
 		goto free_tx_skbuff;
 	}
 
 	tiptr = qe_muram_alloc(32, 32);
-	if (tiptr < 0) {
+	if (tiptr == (unsigned long)-ENOMEM ||
+	    tiptr == (unsigned long)-ENOSYS) {
 		dev_err(priv->dev, "Cannot allocate MURAM mem for Transmit internal temp data pointer\n");
 		ret = -ENOMEM;
 		goto free_riptr;
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ