[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABvMjLTzcwN5h+Fn-nNc4VcSr71skh-813u+mCb+EW5wGOT0+g@mail.gmail.com>
Date: Thu, 3 Oct 2019 10:42:58 -0700
From: Yizhuo Zhai <yzhai003@....edu>
To: David Miller <davem@...emloft.net>
Cc: Chengyu Song <csong@...ucr.edu>, Zhiyun Qian <zhiyunq@...ucr.edu>,
Yisen Zhuang <yisen.zhuang@...wei.com>,
Salil Mehta <salil.mehta@...wei.com>, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: hisilicon: Fix usage of uninitialized variable in
function mdio_sc_cfg_reg_write()
Hi David:
Thanks for your feedback. "regmap_write()" could also fail and cause
influence on the caller. If patches for "regmap_write()" are needed,
then the title could be changed from "uninitialized use" to "miss
return check".
On Wed, Oct 2, 2019 at 2:22 PM David Miller <davem@...emloft.net> wrote:
>
> From: Yizhuo <yzhai003@....edu>
> Date: Tue, 1 Oct 2019 13:24:39 -0700
>
> > In function mdio_sc_cfg_reg_write(), variable "reg_value" could be
> > uninitialized if regmap_read() fails. However, "reg_value" is used
> > to decide the control flow later in the if statement, which is
> > potentially unsafe.
> >
> > Signed-off-by: Yizhuo <yzhai003@....edu>
>
> Applied, but really this is such a pervasive problem.
>
> So much code doesn't check the return value from either regmap_read
> or regmap_write.
>
> _EVEN_ in the code you are editing, the patch context shows an unchecked
> regmap_write() call.
>
> > @@ -148,11 +148,15 @@ static int mdio_sc_cfg_reg_write(struct hns_mdio_device *mdio_dev,
> > {
> > u32 time_cnt;
> > u32 reg_value;
> > + int ret;
> >
> > regmap_write(mdio_dev->subctrl_vbase, cfg_reg, set_val);
> ^^^^^^^^^^^^
>
> Grepping for regmap_{read,write}() shows how big an issue this is.
>
> I don't know what to do, maybe we can work over time to add checks to
> all calls and then force warnings on unchecked return values so that
> the problem is not introduced in the future.
--
Kind Regards,
Yizhuo Zhai
Computer Science, Graduate Student
University of California, Riverside
Powered by blists - more mailing lists