Re: [PATCH] iw_cxgb4: fix uninitialized variable plen

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 22, 2018 at 08:21:49PM +0530, Potnuri Bharat Teja wrote:
> Fixes the following smatch warning and few more possible cases:
> The patch 94245f4ad9e1: "iw_cxgb4: Support FW write completion WR"
> from Aug 2, 2018, leads to the following static checker warning:
> 
> 	drivers/infiniband/hw/cxgb4/qp.c:651 build_rdma_write_cmpl()
> 	error: uninitialized symbol 'plen'.

So the first one I look at sure actually looks like a bug..

        build_isgl((__be64 *)sq->queue, (__be64 *)&sq->queue[sq->size],
                   wcwr->u.isgl_src, wr->sg_list, wr->num_sge, &plen);

        size = sizeof(*wcwr) + sizeof(struct fw_ri_isgl) +
                wr->num_sge * sizeof(struct fw_ri_sge);
        wcwr->plen = cpu_to_be32(plen);

And build_isgl:

static int build_isgl(__be64 *queue_start, __be64 *queue_end,
                      struct fw_ri_isgl *isglp, struct ib_sge *sg_list,
                      int num_sge, u32 *plenp)

{
        int i;
        u32 plen = 0;
        __be64 *flitp;

        if ((__be64 *)isglp == queue_end)
                isglp = (struct fw_ri_isgl *)queue_start;

        flitp = (__be64 *)isglp->sge;

        for (i = 0; i < num_sge; i++) {
                if ((plen + sg_list[i].length) < plen)
                        return -EMSGSIZE;

So yes, plen is uninited because the error check for build_isgl was
skipped.

If error checking is skippable I suggest you init plen in build_isgl
instead of sprinkling =0's all over the place.

Jason



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux