summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorCezary Rojewski <cezary.rojewski@intel.com>2023-10-06 13:28:55 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-11-28 19:46:32 +0300
commit758c7733cb821041f5fd403b7b97c0b95d319323 (patch)
tree9aa2828a950cefcdff252738dc5eb43969cc26de /sound
parent6fceb9fe96ed249ff67877a6cbc3b295620f4ce4 (diff)
downloadlinux-758c7733cb821041f5fd403b7b97c0b95d319323.tar.xz
ALSA: hda: Fix possible null-ptr-deref when assigning a stream
[ Upstream commit f93dc90c2e8ed664985e366aa6459ac83cdab236 ] While AudioDSP drivers assign streams exclusively of HOST or LINK type, nothing blocks a user to attempt to assign a COUPLED stream. As supplied substream instance may be a stub, what is the case when code-loading, such scenario ends with null-ptr-deref. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20231006102857.749143-2-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/hda/hdac_stream.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c
index eee422390d8e..2569f82b6fa0 100644
--- a/sound/hda/hdac_stream.c
+++ b/sound/hda/hdac_stream.c
@@ -241,8 +241,10 @@ struct hdac_stream *snd_hdac_stream_assign(struct hdac_bus *bus,
struct hdac_stream *res = NULL;
/* make a non-zero unique key for the substream */
- int key = (substream->pcm->device << 16) | (substream->number << 2) |
- (substream->stream + 1);
+ int key = (substream->number << 2) | (substream->stream + 1);
+
+ if (substream->pcm)
+ key |= (substream->pcm->device << 16);
list_for_each_entry(azx_dev, &bus->stream_list, list) {
if (azx_dev->direction != substream->stream)