linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit
@ 2018-07-04 14:18 Gustavo A. R. Silva
  2018-07-04 19:53 ` [alsa-devel] " Nicolin Chen
  2018-07-05 10:08 ` Applied "ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit" to the asoc tree Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-04 14:18 UTC (permalink / raw)
  To: Timur Tabi, Nicolin Chen, Xiubo Li, Fabio Estevam, Liam Girdwood,
	Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linuxppc-dev, linux-kernel, Gustavo A. R. Silva

Add suffix ULL to constant 64 in order to give the compiler complete
information about the proper arithmetic to use.

Notice that such constant is used in a context that expects an
expression of type u64 (64 bits, unsigned) and the following
expression is currently being evaluated using 32-bit arithmetic:

rate[index] * txclk_df * 64

Addresses-Coverity-ID: 1222129 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 sound/soc/fsl/fsl_spdif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index 9b59d87..740b90d 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -1118,7 +1118,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
 
 	for (sysclk_df = sysclk_dfmin; sysclk_df <= sysclk_dfmax; sysclk_df++) {
 		for (txclk_df = 1; txclk_df <= 128; txclk_df++) {
-			rate_ideal = rate[index] * txclk_df * 64;
+			rate_ideal = rate[index] * txclk_df * 64ULL;
 			if (round)
 				rate_actual = clk_round_rate(clk, rate_ideal);
 			else
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [alsa-devel] [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit
  2018-07-04 14:18 [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-07-04 19:53 ` Nicolin Chen
  2018-07-05 10:08 ` Applied "ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit" to the asoc tree Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolin Chen @ 2018-07-04 19:53 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Timur Tabi, Xiubo Li, Fabio Estevam, Liam Girdwood, Mark Brown,
	Jaroslav Kysela, Takashi Iwai, alsa-devel, linuxppc-dev,
	linux-kernel

On Wed, Jul 04, 2018 at 09:18:33AM -0500, Gustavo A. R. Silva wrote:
> Add suffix ULL to constant 64 in order to give the compiler complete
> information about the proper arithmetic to use.
> 
> Notice that such constant is used in a context that expects an
> expression of type u64 (64 bits, unsigned) and the following
> expression is currently being evaluated using 32-bit arithmetic:
> 
> rate[index] * txclk_df * 64
> 
> Addresses-Coverity-ID: 1222129 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>

Thanks.

> ---
>  sound/soc/fsl/fsl_spdif.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
> index 9b59d87..740b90d 100644
> --- a/sound/soc/fsl/fsl_spdif.c
> +++ b/sound/soc/fsl/fsl_spdif.c
> @@ -1118,7 +1118,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
>  
>  	for (sysclk_df = sysclk_dfmin; sysclk_df <= sysclk_dfmax; sysclk_df++) {
>  		for (txclk_df = 1; txclk_df <= 128; txclk_df++) {
> -			rate_ideal = rate[index] * txclk_df * 64;
> +			rate_ideal = rate[index] * txclk_df * 64ULL;
>  			if (round)
>  				rate_actual = clk_round_rate(clk, rate_ideal);
>  			else
> -- 
> 2.7.4
> 
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Applied "ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit" to the asoc tree
  2018-07-04 14:18 [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
  2018-07-04 19:53 ` [alsa-devel] " Nicolin Chen
@ 2018-07-05 10:08 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2018-07-05 10:08 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: Nicolin Chen, Mark Brown, Timur Tabi, Nicolin Chen, Xiubo Li,
	Fabio Estevam, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linuxppc-dev, linux-kernel,
	Gustavo A. R. Silva, alsa-devel

The patch

   ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit

has been applied to the asoc tree at

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

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

>From b999a7a9e72bd2d37b5d03772cedfc4dd45875bf Mon Sep 17 00:00:00 2001
From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Wed, 4 Jul 2018 09:18:33 -0500
Subject: [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit

Add suffix ULL to constant 64 in order to give the compiler complete
information about the proper arithmetic to use.

Notice that such constant is used in a context that expects an
expression of type u64 (64 bits, unsigned) and the following
expression is currently being evaluated using 32-bit arithmetic:

rate[index] * txclk_df * 64

Addresses-Coverity-ID: 1222129 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Acked-by: Nicolin Chen <nicoleotsuka@gmail.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/fsl/fsl_spdif.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c
index 9b59d87b61bf..740b90df44bb 100644
--- a/sound/soc/fsl/fsl_spdif.c
+++ b/sound/soc/fsl/fsl_spdif.c
@@ -1118,7 +1118,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv,
 
 	for (sysclk_df = sysclk_dfmin; sysclk_df <= sysclk_dfmax; sysclk_df++) {
 		for (txclk_df = 1; txclk_df <= 128; txclk_df++) {
-			rate_ideal = rate[index] * txclk_df * 64;
+			rate_ideal = rate[index] * txclk_df * 64ULL;
 			if (round)
 				rate_actual = clk_round_rate(clk, rate_ideal);
 			else
-- 
2.18.0.rc2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-05 10:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-04 14:18 [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-07-04 19:53 ` [alsa-devel] " Nicolin Chen
2018-07-05 10:08 ` Applied "ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit" to the asoc tree Mark Brown

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).