mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@st.com>
To: Yizhuo <yzhai003@ucr.edu>
Cc: "csong@cs.ucr.edu" <csong@cs.ucr.edu>,
	"zhiyunq@cs.ucr.edu" <zhiyunq@cs.ucr.edu>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized
Date: Wed, 6 Feb 2019 08:39:46 +0000	[thread overview]
Message-ID: <a5bf0f11-3428-92de-e37a-96cce1952b36@st.com> (raw)
In-Reply-To: <20190206033036.22729-1-yzhai003@ucr.edu>

Hi Yizhuo

On 2/6/19 4:30 AM, Yizhuo wrote:
> In function miphy_osc_is_ready(), local variable "val"
> could be uninitalized. if function regmap_read() returns
> -EINVAL. However, this value is used in if statement.
> This is potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/phy/st/phy-miphy28lp.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c
> index 213e2e15339c..40c7c0a611a0 100644
> --- a/drivers/phy/st/phy-miphy28lp.c
> +++ b/drivers/phy/st/phy-miphy28lp.c
> @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  {
>  	struct miphy28lp_dev *miphy_dev = miphy_phy->phydev;
>  	unsigned long finish = jiffies + 5 * HZ;
> -	u32 val;
> +	u32 val = 0;
> +	int ret;
>  
>  	if (!miphy_phy->osc_rdy)
>  		return 0;
> @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy)
>  		return -EINVAL;
>  
>  	do {
> -		regmap_read(miphy_dev->regmap,
> +		ret = regmap_read(miphy_dev->regmap,
>  				miphy_phy->syscfg_reg[SYSCFG_STATUS], &val);
> +		if (ret)
> +			return ret;
>  
>  		if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY)
>  			cpu_relax();
> 

Reviewed-by: Patrice Chotard <patrice.chotard@st.com>

Thanks

  reply	other threads:[~2019-02-06  8:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-06  3:30 Yizhuo
2019-02-06  8:39 ` Patrice CHOTARD [this message]
2019-02-06 11:36 ` Kishon Vijay Abraham I
  -- strict thread matches above, loose matches on Subject: below --
2019-02-06  3:12 Yizhuo

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=a5bf0f11-3428-92de-e37a-96cce1952b36@st.com \
    --to=patrice.chotard@st.com \
    --cc=csong@cs.ucr.edu \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yzhai003@ucr.edu \
    --cc=zhiyunq@cs.ucr.edu \
    /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

all inboxes | Powered by JetHome®