diff mbox series

[1/1] ASoC: topology: Fix variable overflow in split_format

Message ID 1566820301-18671-1-git-send-email-marcin.pietraszko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/1] ASoC: topology: Fix variable overflow in split_format | expand

Commit Message

Marcin Pietraszko Aug. 26, 2019, 11:51 a.m. UTC
The 1 which was 32-bit long, when left-shifted by more than 31 caused
an overflow, which resulted in some of the formats being not supported.

Signed-off-by: Marcin Pietraszko <marcin.pietraszko@linux.intel.com>
---
 src/topology/pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pierre-Louis Bossart Aug. 26, 2019, 4:59 p.m. UTC | #1
CC: Takashi and Mark.

On 8/26/19 6:51 AM, Marcin Pietraszko wrote:
> The 1 which was 32-bit long, when left-shifted by more than 31 caused
> an overflow, which resulted in some of the formats being not supported.

Looks like an alsa-lib patch?

> 
> Signed-off-by: Marcin Pietraszko <marcin.pietraszko@linux.intel.com>
> ---
>   src/topology/pcm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/topology/pcm.c b/src/topology/pcm.c
> index 5f586dc..00a35b9 100644
> --- a/src/topology/pcm.c
> +++ b/src/topology/pcm.c
> @@ -321,7 +321,7 @@ static int split_format(struct snd_soc_tplg_stream_caps *caps, char *str)
>   			return -EINVAL;
>   		}
>   
> -		caps->formats |= 1 << format;
> +		caps->formats |= 1ull << format;
>   		s = strtok(NULL, ", ");
>   		i++;
>   	}
>
Takashi Iwai Aug. 27, 2019, 7:38 a.m. UTC | #2
On Mon, 26 Aug 2019 18:59:16 +0200,
Pierre-Louis Bossart wrote:
> 
> CC: Takashi and Mark.
> 
> On 8/26/19 6:51 AM, Marcin Pietraszko wrote:
> > The 1 which was 32-bit long, when left-shifted by more than 31 caused
> > an overflow, which resulted in some of the formats being not supported.
> 
> Looks like an alsa-lib patch?

Seems so.  I applied to alsa-lib repo now.


thanks,

Takashi


> 
> >
> > Signed-off-by: Marcin Pietraszko <marcin.pietraszko@linux.intel.com>
> > ---
> >   src/topology/pcm.c | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/src/topology/pcm.c b/src/topology/pcm.c
> > index 5f586dc..00a35b9 100644
> > --- a/src/topology/pcm.c
> > +++ b/src/topology/pcm.c
> > @@ -321,7 +321,7 @@ static int split_format(struct snd_soc_tplg_stream_caps *caps, char *str)
> >   			return -EINVAL;
> >   		}
> >   -		caps->formats |= 1 << format;
> > +		caps->formats |= 1ull << format;
> >   		s = strtok(NULL, ", ");
> >   		i++;
> >   	}
> >
>
diff mbox series

Patch

diff --git a/src/topology/pcm.c b/src/topology/pcm.c
index 5f586dc..00a35b9 100644
--- a/src/topology/pcm.c
+++ b/src/topology/pcm.c
@@ -321,7 +321,7 @@  static int split_format(struct snd_soc_tplg_stream_caps *caps, char *str)
 			return -EINVAL;
 		}
 
-		caps->formats |= 1 << format;
+		caps->formats |= 1ull << format;
 		s = strtok(NULL, ", ");
 		i++;
 	}