lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 20 Mar 2019 15:23:44 -0700
From:   Nick Desaulniers <ndesaulniers@...gle.com>
To:     Nathan Chancellor <natechancellor@...il.com>
Cc:     "James E.J. Bottomley" <jejb@...ux.ibm.com>,
        "Martin K. Petersen" <martin.petersen@...cle.com>,
        Stanley Chu <stanley.chu@...iatek.com>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Alim Akhtar <alim.akhtar@...sung.com>,
        Avri Altman <avri.altman@....com>,
        Pedro Sousa <pedrom.sousa@...opsys.com>,
        linux-scsi@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
        Linux ARM <linux-arm-kernel@...ts.infradead.org>,
        linux-mediatek@...ts.infradead.org,
        clang-built-linux@...glegroups.com
Subject: Re: [PATCH] scsi: ufs-mediatek: Avoid using ret uninitialized in ufs_mtk_setup_clocks

On Wed, Mar 20, 2019 at 11:06 AM Nathan Chancellor
<natechancellor@...il.com> wrote:
>
> When building with -Wsometimes-uninitialized, Clang warns:
>
> drivers/scsi/ufs/ufs-mediatek.c:112:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
>                 if (on)
>                     ^~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
>         return ret;
>                ^~~
> drivers/scsi/ufs/ufs-mediatek.c:112:3: note: remove the 'if' if its
> condition is always true
>                 if (on)
>                 ^~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:108:7: warning: variable 'ret' is used
> uninitialized whenever 'if' condition is false
> [-Wsometimes-uninitialized]
>                 if (!on)
>                     ^~~
> drivers/scsi/ufs/ufs-mediatek.c:120:9: note: uninitialized use occurs
> here
>         return ret;
>                ^~~
> drivers/scsi/ufs/ufs-mediatek.c:108:3: note: remove the 'if' if its
> condition is always true
>                 if (!on)
>                 ^~~~~~~~
> drivers/scsi/ufs/ufs-mediatek.c:96:9: note: initialize the variable
> 'ret' to silence this warning
>         int ret;
>                ^
>                 = 0
> 2 warnings generated.
>
> Remove the default case and initialize ret to -EINVAL to properly fix
> this warning.
>
> Fixes: ddd90623ce26 ("scsi: ufs-mediatek: Add UFS support for Mediatek SoC chips")
> Link: https://github.com/ClangBuiltLinux/linux/issues/426
> Signed-off-by: Nathan Chancellor <natechancellor@...il.com>
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-mediatek.c
> index c3b78fc83d3f..34aecad04468 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -93,7 +93,7 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
>                                 enum ufs_notify_change_status status)
>  {
>         struct ufs_mtk_host *host = ufshcd_get_variant(hba);
> -       int ret;
> +       int ret = -EINVAL;
>
>         /*
>          * In case ufs_mtk_init() is not yet done, simply ignore.
> @@ -112,9 +112,6 @@ static int ufs_mtk_setup_clocks(struct ufs_hba *hba, bool on,
>                 if (on)
>                         ret = phy_power_on(host->mphy);
>                 break;
> -       default:
> -               ret = -EINVAL;
> -               break;
>         }
>
>         return ret;
> --
> 2.21.0
>

The enum being switched on (enum ufs_notify_change_status) only has 2
values; so the default case is impossible.  A switch is probably
overkill, but this change is fine as is.  Thanks for sending it.
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
-- 
Thanks,
~Nick Desaulniers

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ