Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4130a6b8 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ALSA: pcm: check for integer overflow during multiplication"

parents 41583ec3 b0b44cce
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1720,6 +1720,11 @@ static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream,
	switch (runtime->access) {
	case SNDRV_PCM_ACCESS_MMAP_INTERLEAVED:
	case SNDRV_PCM_ACCESS_RW_INTERLEAVED:
		if ((UINT_MAX/width) < info->channel) {
			snd_printd("%s: integer overflow while multiply\n",
				   __func__);
			return -EINVAL;
		}
		info->first = info->channel * width;
		info->step = runtime->channels * width;
		break;
@@ -1727,6 +1732,12 @@ static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream,
	case SNDRV_PCM_ACCESS_RW_NONINTERLEAVED:
	{
		size_t size = runtime->dma_bytes / runtime->channels;

		if ((size > 0) && ((UINT_MAX/(size * 8)) < info->channel)) {
			snd_printd("%s: integer overflow while multiply\n",
				   __func__);
			return -EINVAL;
		}
		info->first = info->channel * size * 8;
		info->step = width;
		break;