linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [bug report] infiniband/hw/mthca: ancient uninitialized variable
@ 2023-11-02  7:50 Dan Carpenter
  2023-11-02 13:00 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2023-11-02  7:50 UTC (permalink / raw)
  To: linux-rdma; +Cc: Hiatt, Don

[ 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,

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'.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [bug report] infiniband/hw/mthca: ancient uninitialized variable
  2023-11-02  7:50 [bug report] infiniband/hw/mthca: ancient uninitialized variable Dan Carpenter
@ 2023-11-02 13:00 ` Leon Romanovsky
  0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2023-11-02 13:00 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: linux-rdma, Hiatt, Don

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-11-02 13:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-11-02  7:50 [bug report] infiniband/hw/mthca: ancient uninitialized variable Dan Carpenter
2023-11-02 13:00 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).