public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Bunk <bunk@stusta.de>
To: Steve Wise <swise@opengridcomputing.com>,
	Roland Dreier <rolandd@cisco.com>
Cc: mshefty@ichips.intel.com, halr@voltaire.com,
	openib-general@openib.org, linux-kernel@vger.kernel.org
Subject: drivers/infiniband/hw/cxgb3/iwch_provider.c: uninitialized variable used
Date: Mon, 19 Mar 2007 10:26:55 +0100	[thread overview]
Message-ID: <20070319092655.GR752@stusta.de> (raw)

The Coverity checker spotted that "npages" will be used uninitialized in 
the following code if !(mr_rereg_mask & IB_MR_REREG_TRANS):

<--  snip  -->

...
static int iwch_reregister_phys_mem(struct ib_mr *mr,
                                     int mr_rereg_mask,
                                     struct ib_pd *pd,
                                     struct ib_phys_buf *buffer_list,
                                     int num_phys_buf,
                                     int acc, u64 * iova_start)
{

        struct iwch_mr mh, *mhp;
        struct iwch_pd *php;
        struct iwch_dev *rhp;
        __be64 *page_list = NULL;
        int shift = 0;
        u64 total_size;
        int npages;
        int ret;

        PDBG("%s ib_mr %p ib_pd %p\n", __FUNCTION__, mr, pd);

        /* There can be no memory windows */
        if (atomic_read(&mr->usecnt))
                return -EINVAL;

        mhp = to_iwch_mr(mr);
        rhp = mhp->rhp;
        php = to_iwch_pd(mr->pd);

        /* make sure we are on the same adapter */
        if (rhp != php->rhp)
                return -EINVAL;

        memcpy(&mh, mhp, sizeof *mhp);

        if (mr_rereg_mask & IB_MR_REREG_PD)
                php = to_iwch_pd(pd);
        if (mr_rereg_mask & IB_MR_REREG_ACCESS)
                mh.attr.perms = iwch_ib_to_tpt_access(acc);
        if (mr_rereg_mask & IB_MR_REREG_TRANS)
                ret = build_phys_page_list(buffer_list, num_phys_buf,
                                           iova_start,
                                           &total_size, &npages,
                                           &shift, &page_list);

        ret = iwch_reregister_mem(rhp, php, &mh, shift, page_list, npages);
...

<--  snip  -->

Looking at the code, it also seems some orignally planned error handling 
code for the build_phys_page_list() call was forgotten ("ret" is never 
checked before it's overwritten again).

cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


             reply	other threads:[~2007-03-19  9:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-19  9:26 Adrian Bunk [this message]
2007-03-19 14:05 ` drivers/infiniband/hw/cxgb3/iwch_provider.c: uninitialized variable used Steve Wise

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070319092655.GR752@stusta.de \
    --to=bunk@stusta.de \
    --cc=halr@voltaire.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mshefty@ichips.intel.com \
    --cc=openib-general@openib.org \
    --cc=rolandd@cisco.com \
    --cc=swise@opengridcomputing.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox