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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 14 Jun 2022 09:19:14 +0800
From:   Mark Zhang <markzhang@...dia.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>, jgg@...pe.ca
Cc:     leon@...nel.org, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org, Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] RDMA/cm: fix cond_no_effect.cocci warnings

On 6/10/2022 5:45 PM, Jiapeng Chong wrote:
> This was found by coccicheck:
> 
> ./drivers/infiniband/core/cm.c:685:7-9: WARNING: possible condition with no effect (if == else).
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
>   drivers/infiniband/core/cm.c | 9 ++-------
>   1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index 1c107d6d03b9..bb6a2b6b9657 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -676,14 +676,9 @@ static struct cm_id_private *cm_find_listen(struct ib_device *device,
>   			refcount_inc(&cm_id_priv->refcount);
>   			return cm_id_priv;
>   		}
> -		if (device < cm_id_priv->id.device)
> +		if (device < cm_id_priv->id.device ||
> +		    be64_lt(service_id, cm_id_priv->id.service_id))
>   			node = node->rb_left;
> -		else if (device > cm_id_priv->id.device)
> -			node = node->rb_right;
> -		else if (be64_lt(service_id, cm_id_priv->id.service_id))
> -			node = node->rb_left;
> -		else if (be64_gt(service_id, cm_id_priv->id.service_id))
> -			node = node->rb_right;
>   		else
>   			node = node->rb_right;
>   	}

Not sure if the fix is correct, e.g. with this condition:
   device > cm_id_priv->id.device &&
   be64_lt(service_id, cm_id_priv->id.service_id)

The original code gets rb_right but this fix gets rb_left. Maybe the 
warning is complain about this:
	...
	else if (be64_gt(service_id, cm_id_priv->id.service_id))
		node = node->rb_right;
	else
		node = node->rb_right;

Besides cm_insert_listen() has same logic.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ