linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Colin Ian King <colin.king@canonical.com>
To: Zhou Yanjie <zhouyanjie@wanyeetech.com>,
	Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: USB: PHY: JZ4770: Add support for new Ingenic SoCs - bug report
Date: Mon, 27 Jul 2020 19:08:07 +0100	[thread overview]
Message-ID: <661defa2-ac55-c4bc-7ac1-41657a4552bd@canonical.com> (raw)

Hi,

Static analysis with Coverity has detected an issue with the following
commit:

commit 2a6c0b82e65128c73b5102e00e031c5e58bb3504
Author: 周琰杰 (Zhou Yanjie) <zhouyanjie@wanyeetech.com>
Date:   Thu Jul 23 14:13:00 2020 +0800

    USB: PHY: JZ4770: Add support for new Ingenic SoCs.

The analysis from Coverity is as follows:

157 static int ingenic_usb_phy_init(struct usb_phy *phy)
158 {
159        struct jz4770_phy *priv = phy_to_jz4770_phy(phy);
160        int err;

1. var_decl: Declaring variable reg without initializer.

161        u32 reg;
162
163        err = regulator_enable(priv->vcc_supply);

2. Condition err, taking false branch.

164        if (err) {
165                dev_err(priv->dev, "Unable to enable VCC: %d\n", err);
166                return err;
167        }
168
169        err = clk_prepare_enable(priv->clk);

3. Condition err, taking false branch.

170        if (err) {
171                dev_err(priv->dev, "Unable to start clock: %d\n", err);
172                return err;
173        }
174
175        priv->soc_info->usb_phy_init(phy);
176
177        /* Wait for PHY to reset */
178        usleep_range(30, 300);

Uninitialized scalar variable (UNINIT)
4. uninit_use: Using uninitialized value reg.

179        writel(reg & ~USBPCR_POR, priv->base + REG_USBPCR_OFFSET);
180        usleep_range(300, 1000);
181
182        return 0;
183 }


The commit removed the setting of reg in the change:

-       reg = USBPCR_AVLD_REG | USBPCR_COMMONONN | USBPCR_IDPULLUP_ALWAYS |
-               USBPCR_COMPDISTUNE_DFT | USBPCR_OTGTUNE_DFT |
USBPCR_SQRXTUNE_DFT |
-               USBPCR_TXFSLSTUNE_DFT | USBPCR_TXRISETUNE_DFT |
USBPCR_TXVREFTUNE_DFT |
-               USBPCR_POR;
-       writel(reg, priv->base + REG_USBPCR_OFFSET);

Colin

                 reply	other threads:[~2020-07-27 18:08 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=661defa2-ac55-c4bc-7ac1-41657a4552bd@canonical.com \
    --to=colin.king@canonical.com \
    --cc=balbi@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=zhouyanjie@wanyeetech.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;
as well as URLs for NNTP newsgroup(s).