Skip to contentSkip to conversation

ASoC: topology: Fix variable overflow in split_format

PATCH In review Marcin Pietraszko 3 participants 3 messages Aug 26, 2019 – Aug 27, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: topology: Fix variable overflow in split_format

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.

---
 src/topology/pcm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/topology/pcm.c +1 -1
index 5f586dc..00a35b9 100644
@@ -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++;
 	}
Signature · 1 line
2.7.4
#1 lore raw
CC Takashi and Mark.
Quoted 2 lines · Marcin Pietraszko

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?

Quoted 20 lines
---
  src/topology/pcm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/topology/pcm.c +1 -1
index 5f586dc..00a35b9 100644
@@ -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++;
  	}
#2 lore raw
Quoted 8 lines · Pierre-Louis Bossart
CC Takashi and Mark.
Quoted 2 lines · Marcin Pietraszko

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

Quoted 21 lines
Quoted 20 lines
---
  src/topology/pcm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
src/topology/pcm.c +1 -0
index 5f586dc..00a35b9 100644
@@ -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++;
  	}