Skip to content

Commit

Permalink
ALSA: hda: Fix possible null-ptr-deref when assigning a stream
Browse files Browse the repository at this point in the history
[ Upstream commit f93dc90 ]

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>
  • Loading branch information
crojewsk-intel authored and gregkh committed Nov 28, 2023
1 parent c23ff8e commit fe7c1a0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sound/hda/hdac_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,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);

spin_lock_irq(&bus->reg_lock);
list_for_each_entry(azx_dev, &bus->stream_list, list) {
Expand Down

0 comments on commit fe7c1a0

Please sign in to comment.