Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: linux-rdma@vger.kernel.org, Hiatt@moroto, Don <don.hiatt@intel.com>
Subject: Re: [bug report] infiniband/hw/mthca: ancient uninitialized variable
Date: Thu, 2 Nov 2023 15:00:23 +0200	[thread overview]
Message-ID: <20231102130023.GG5885@unreal> (raw)
In-Reply-To: <533bc3df-8078-4397-b93d-d1f6cec9b636@moroto.mountain>

On Thu, Nov 02, 2023 at 10:50:36AM +0300, Dan Carpenter wrote:
> [ This code is very old, but it's also very obviously buggy.  Does
>   anyone know what a good default "out =" value should be? - dan ]
> 
> Hello Linus Torvalds,

Hi,

> 
> The patch 1da177e4c3f4: "Linux-2.6.12-rc2" from Apr 16, 2005
> (linux-next), leads to the following Smatch static checker warning:
> 
> 	drivers/infiniband/hw/mthca/mthca_cmd.c:644 mthca_SYS_EN()
> 	error: uninitialized symbol 'out'.

Thanks for the report, I'll send a patch after merge window.

> 
> drivers/infiniband/hw/mthca/mthca_cmd.c
>     636 int mthca_SYS_EN(struct mthca_dev *dev)
>     637 {
>     638         u64 out;
>     639         int ret;
>     640 
>     641         ret = mthca_cmd_imm(dev, 0, &out, 0, 0, CMD_SYS_EN, CMD_TIME_CLASS_D);
> 
> We pass out here and it gets used without being initialized.
> 
>         err = mthca_cmd_post(dev, in_param,
>                              out_param ? *out_param : 0,
>                                          ^^^^^^^^^^
>                              in_modifier, op_modifier,
>                              op, context->token, 1);
> 
> It's the same in mthca_cmd_wait() and mthca_cmd_poll().
> 
>     642 
>     643         if (ret == -ENOMEM)
> --> 644                 mthca_warn(dev, "SYS_EN DDR error: syn=%x, sock=%d, "
>     645                            "sladdr=%d, SPD source=%s\n",
>     646                            (int) (out >> 6) & 0xf, (int) (out >> 4) & 3,
>     647                            (int) (out >> 1) & 7, (int) out & 1 ? "NVMEM" : "DIMM");
>     648 
>     649         return ret;
>     650 }
> 
> regards,
> dan carpenter

      reply	other threads:[~2023-11-02 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-02  7:50 [bug report] infiniband/hw/mthca: ancient uninitialized variable Dan Carpenter
2023-11-02 13:00 ` Leon Romanovsky [this message]

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=20231102130023.GG5885@unreal \
    --to=leon@kernel.org \
    --cc=Hiatt@moroto \
    --cc=dan.carpenter@linaro.org \
    --cc=don.hiatt@intel.com \
    --cc=linux-rdma@vger.kernel.org \
    /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