diff mbox series

[1/2] net: phy: fix yt8511 clang uninitialized variable warning

Message ID 20210525122615.3972574-2-pgwipeout@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series fixes for yt8511 phy driver | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Guessed tree name to be net-next
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cc_maintainers warning 1 maintainers not CCed: ndesaulniers@google.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes fail Link
netdev/checkpatch warning WARNING: Unknown commit id 'b1b41c047f73', maybe rebased or not pulled?
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Peter Geis May 25, 2021, 12:26 p.m. UTC
clang doesn't preinitialize variables. If phy_select_page failed and
returned an error, phy_restore_page would be called with `ret` being
uninitialized.
Even though phy_restore_page won't use `ret` in this scenario,
initialize `ret` to silence the warning.

Fixes: b1b41c047f73 ("net: phy: add driver for Motorcomm yt8511 phy")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Peter Geis <pgwipeout@gmail.com>
---
 drivers/net/phy/motorcomm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andrew Lunn May 25, 2021, 1:01 p.m. UTC | #1
On Tue, May 25, 2021 at 08:26:14AM -0400, Peter Geis wrote:
> clang doesn't preinitialize variables. If phy_select_page failed and
> returned an error, phy_restore_page would be called with `ret` being
> uninitialized.
> Even though phy_restore_page won't use `ret` in this scenario,
> initialize `ret` to silence the warning.
> 
> Fixes: b1b41c047f73 ("net: phy: add driver for Motorcomm yt8511 phy")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> ---
>  drivers/net/phy/motorcomm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
> index 796b68f4b499..5795f446c528 100644
> --- a/drivers/net/phy/motorcomm.c
> +++ b/drivers/net/phy/motorcomm.c
> @@ -51,7 +51,7 @@ static int yt8511_write_page(struct phy_device *phydev, int page)
>  static int yt8511_config_init(struct phy_device *phydev)
>  {
>  	unsigned int ge, fe;
> -	int ret, oldpage;
> +	int oldpage, ret = 0;

Please keep to reverse Christmas tree.

With that fixed:

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew
Peter Geis May 25, 2021, 1:11 p.m. UTC | #2
On Tue, May 25, 2021 at 9:02 AM Andrew Lunn <andrew@lunn.ch> wrote:
>
> On Tue, May 25, 2021 at 08:26:14AM -0400, Peter Geis wrote:
> > clang doesn't preinitialize variables. If phy_select_page failed and
> > returned an error, phy_restore_page would be called with `ret` being
> > uninitialized.
> > Even though phy_restore_page won't use `ret` in this scenario,
> > initialize `ret` to silence the warning.
> >
> > Fixes: b1b41c047f73 ("net: phy: add driver for Motorcomm yt8511 phy")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Peter Geis <pgwipeout@gmail.com>
> > ---
> >  drivers/net/phy/motorcomm.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
> > index 796b68f4b499..5795f446c528 100644
> > --- a/drivers/net/phy/motorcomm.c
> > +++ b/drivers/net/phy/motorcomm.c
> > @@ -51,7 +51,7 @@ static int yt8511_write_page(struct phy_device *phydev, int page)
> >  static int yt8511_config_init(struct phy_device *phydev)
> >  {
> >       unsigned int ge, fe;
> > -     int ret, oldpage;
> > +     int oldpage, ret = 0;
>
> Please keep to reverse Christmas tree.

Ah, I missed that.
Do you want a v2 or will it be fixed on application?

>
> With that fixed:
>
> Reviewed-by: Andrew Lunn <andrew@lunn.ch>
>
>     Andrew

Thanks!
Peter
Andrew Lunn May 25, 2021, 1:59 p.m. UTC | #3
> Do you want a v2 or will it be fixed on application?

A v2. And please remember to add the Reviewed-by tags.

  Andrew
diff mbox series

Patch

diff --git a/drivers/net/phy/motorcomm.c b/drivers/net/phy/motorcomm.c
index 796b68f4b499..5795f446c528 100644
--- a/drivers/net/phy/motorcomm.c
+++ b/drivers/net/phy/motorcomm.c
@@ -51,7 +51,7 @@  static int yt8511_write_page(struct phy_device *phydev, int page)
 static int yt8511_config_init(struct phy_device *phydev)
 {
 	unsigned int ge, fe;
-	int ret, oldpage;
+	int oldpage, ret = 0;
 
 	/* set clock mode to 125mhz */
 	oldpage = phy_select_page(phydev, YT8511_EXT_CLK_GATE);