diff mbox series

[v2] ASoC: amd: ps: Fix uninitialized ret in create_acp64_platform_devs()

Message ID 20230105-wsometimes-uninitialized-pci-ps-c-v2-1-c50321676325@kernel.org
State Accepted
Commit de1cae22898cf10aacc735a21d799b5bbce4496c
Headers show
Series [v2] ASoC: amd: ps: Fix uninitialized ret in create_acp64_platform_devs() | expand

Commit Message

Nathan Chancellor Jan. 6, 2023, 12:43 a.m. UTC
Clang warns:

  sound/soc/amd/ps/pci-ps.c:218:2: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
          default:
          ^~~~~~~
  sound/soc/amd/ps/pci-ps.c:239:9: note: uninitialized use occurs here
          return ret;
                 ^~~
  sound/soc/amd/ps/pci-ps.c:190:9: note: initialize the variable 'ret' to silence this warning
          int ret;
                 ^
                  = 0
  1 error generated.

ret is used uninitialized if 'goto de_init' is taken. As this is not an
error nor should the ACP be deinitialized, just directly return 0 in
this case statement, which resolves the warning.

Fixes: 1d325cdaf7a2 ("ASoC: amd: ps: refactor platform device creation logic")
Link: https://github.com/ClangBuiltLinux/linux/issues/1779
Suggested-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
Changes in v2:
- Instead of setting ret to -ENODEV and going to de_init, just 'return 0' in
  the default case (Vijendar)
Link to v1: https://lore.kernel.org/r/20230105-wsometimes-uninitialized-pci-ps-c-v1-1-4022fd077959@kernel.org
---
 sound/soc/amd/ps/pci-ps.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


---
base-commit: 03178b4f7e2c59ead102e5ab5acb82ce1eaefe46
change-id: 20230105-wsometimes-uninitialized-pci-ps-c-3b5725c6ed31

Best regards,

Comments

syed saba kareem Jan. 9, 2023, 11:30 a.m. UTC | #1
On 1/6/23 06:13, Nathan Chancellor wrote:
> Clang warns:
>
>    sound/soc/amd/ps/pci-ps.c:218:2: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
>            default:
>            ^~~~~~~
>    sound/soc/amd/ps/pci-ps.c:239:9: note: uninitialized use occurs here
>            return ret;
>                   ^~~
>    sound/soc/amd/ps/pci-ps.c:190:9: note: initialize the variable 'ret' to silence this warning
>            int ret;
>                   ^
>                    = 0
>    1 error generated.
>
> ret is used uninitialized if 'goto de_init' is taken. As this is not an
> error nor should the ACP be deinitialized, just directly return 0 in
> this case statement, which resolves the warning.
>
> Fixes: 1d325cdaf7a2 ("ASoC: amd: ps: refactor platform device creation logic")
> Link: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FClangBuiltLinux%2Flinux%2Fissues%2F1779&data=05%7C01%7CSyed.SabaKareem%40amd.com%7Cab19d64e997043ee07ae08daef7f10d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638085626264112039%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=ximBlRFOMQKg0q6Rac19%2FaVNnyNaBUfkHm9Me5NYj2k%3D&reserved=0
> Suggested-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>

Reviewed-by : Syed Saba Kareem<syed.sabakareem@amd.com>

> ---
> Changes in v2:
> - Instead of setting ret to -ENODEV and going to de_init, just 'return 0' in
>    the default case (Vijendar)
> Link to v1: https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fr%2F20230105-wsometimes-uninitialized-pci-ps-c-v1-1-4022fd077959%40kernel.org&data=05%7C01%7CSyed.SabaKareem%40amd.com%7Cab19d64e997043ee07ae08daef7f10d0%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C638085626264112039%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=rjsus%2BLxO7v%2F94R48F8VxQXtkt8QnibZLcCbEFLq%2F1g%3D&reserved=0
> ---
>   sound/soc/amd/ps/pci-ps.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c
> index 401cfd0036be..64648b75de6b 100644
> --- a/sound/soc/amd/ps/pci-ps.c
> +++ b/sound/soc/amd/ps/pci-ps.c
> @@ -217,7 +217,7 @@ static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data
>   		break;
>   	default:
>   		dev_dbg(&pci->dev, "No PDM devices found\n");
> -		goto de_init;
> +		return 0;
>   	}
>   
>   	for (index = 0; index < adata->pdev_count; index++) {
>
> ---
> base-commit: 03178b4f7e2c59ead102e5ab5acb82ce1eaefe46
> change-id: 20230105-wsometimes-uninitialized-pci-ps-c-3b5725c6ed31
>
> Best regards,
Mark Brown Jan. 9, 2023, 12:56 p.m. UTC | #2
On Mon, Jan 09, 2023 at 05:00:11PM +0530, syed saba kareem wrote:

> > Suggested-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> > Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> 
> Reviewed-by : Syed Saba Kareem<syed.sabakareem@amd.com>

Note that if you use a different name (here you've got capital letters
on the words in your name) or misformat the line (you've got an extra
space before the colon and are missing one before the email address)
then the tooling won't pick up your tags.
syed saba kareem Jan. 9, 2023, 1:21 p.m. UTC | #3
On 1/9/23 18:26, Mark Brown wrote:
> On Mon, Jan 09, 2023 at 05:00:11PM +0530, syed saba kareem wrote:
>
>>> Suggested-by: Vijendar Mukunda<Vijendar.Mukunda@amd.com>
>>> Signed-off-by: Nathan Chancellor<nathan@kernel.org>
>> Reviewed-by : Syed Saba Kareem<syed.sabakareem@amd.com>
> Note that if you use a different name (here you've got capital letters
> on the words in your name) or misformat the line (you've got an extra
> space before the colon and are missing one before the email address)
> then the tooling won't pick up your tags.

corrected.

Reviewed-by: Syed Saba Kareem<Syed.SabaKareem@amd.com>
Mark Brown Jan. 9, 2023, 4:49 p.m. UTC | #4
On Thu, 05 Jan 2023 17:43:39 -0700, Nathan Chancellor wrote:
> Clang warns:
> 
>   sound/soc/amd/ps/pci-ps.c:218:2: error: variable 'ret' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized]
>           default:
>           ^~~~~~~
>   sound/soc/amd/ps/pci-ps.c:239:9: note: uninitialized use occurs here
>           return ret;
>                  ^~~
>   sound/soc/amd/ps/pci-ps.c:190:9: note: initialize the variable 'ret' to silence this warning
>           int ret;
>                  ^
>                   = 0
>   1 error generated.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: amd: ps: Fix uninitialized ret in create_acp64_platform_devs()
      commit: de1cae22898cf10aacc735a21d799b5bbce4496c

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
diff mbox series

Patch

diff --git a/sound/soc/amd/ps/pci-ps.c b/sound/soc/amd/ps/pci-ps.c
index 401cfd0036be..64648b75de6b 100644
--- a/sound/soc/amd/ps/pci-ps.c
+++ b/sound/soc/amd/ps/pci-ps.c
@@ -217,7 +217,7 @@  static int create_acp63_platform_devs(struct pci_dev *pci, struct acp63_dev_data
 		break;
 	default:
 		dev_dbg(&pci->dev, "No PDM devices found\n");
-		goto de_init;
+		return 0;
 	}
 
 	for (index = 0; index < adata->pdev_count; index++) {