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]
Message-ID: <20170518060038.GB6326@yuval-lap>
Date:   Thu, 18 May 2017 09:00:39 +0300
From:   Yuval Shaia <yuval.shaia@...cle.com>
To:     "Gustavo A. R. Silva" <garsilva@...eddedor.com>
Cc:     Faisal Latif <faisal.latif@...el.com>,
        Shiraz Saleem <shiraz.saleem@...el.com>,
        Doug Ledford <dledford@...hat.com>,
        Sean Hefty <sean.hefty@...el.com>,
        Hal Rosenstock <hal.rosenstock@...il.com>,
        linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [infiniband-hw-i40iw] question about identical code for
 different branches

On Wed, May 17, 2017 at 05:06:54PM -0500, Gustavo A. R. Silva wrote:
> 
> Hello everybody,
> 
> While looking into Coverity ID 1362263 I ran into the following piece of
> code at drivers/infiniband/hw/i40iw/i40iw_virtchnl.c:445:
> 
> 445        if (vchnl_msg->iw_op_code == I40IW_VCHNL_OP_GET_VER) {
> 446                if (vchnl_msg->iw_op_ver != I40IW_VCHNL_OP_GET_VER_V0)
> 447                        vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg);
> 448                else
> 449                        vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg);
> 450                return I40IW_SUCCESS;
> 451        }
> 
> The issue is that lines of code 447 and 449 are identical for different
> branches.
> 
> My question here is if one of the branches should be modified, or the entire
> _if_ statement replaced?
> 
> Maybe a patch like the following could be applied:
> 
> index f4d1368..48fd327 100644
> --- a/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c
> +++ b/drivers/infiniband/hw/i40iw/i40iw_virtchnl.c
> @@ -443,10 +443,7 @@ enum i40iw_status_code i40iw_vchnl_recv_pf(struct
> i40iw_sc_dev *dev,
>         if (!dev->vchnl_up)
>                 return I40IW_ERR_NOT_READY;
>         if (vchnl_msg->iw_op_code == I40IW_VCHNL_OP_GET_VER) {
> -               if (vchnl_msg->iw_op_ver != I40IW_VCHNL_OP_GET_VER_V0)
> -                       vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg);
> -               else
> -                       vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg);
> +               vchnl_pf_send_get_ver_resp(dev, vf_id, vchnl_msg);
>                 return I40IW_SUCCESS;
>         }
>         for (iw_vf_idx = 0; iw_vf_idx < I40IW_MAX_PE_ENABLED_VF_COUNT;
> iw_vf_idx++) {
> 
> What do you think?

This looks like a nice catch!

Reviewed-by: Yuval Shaia <yuval.shaia@...cle.com>

> 
> I'd really appreciate any comment on this.
> 
> Thank you!
> --
> Gustavo A. R. Silva
> 
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ