From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52672381D6; Fri, 24 Nov 2023 17:57:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Pz3yc5H8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0773C433CA; Fri, 24 Nov 2023 17:57:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1700848643; bh=Xc7OLJn2gBG864ymaZZvOPCiIvu93nyeyZ1334SfrWk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pz3yc5H81ztqk1Z2gjkbNvFwPV4ifX+U6AaJbyTU+SfRDN1YK3VYDMvJ6+ULRE/cx 8ZIMhTbjSmTsQBhtlTHrdNPoafr9v+zXGmhK1VI6BA9uokitaAd1eZceDzDaQSJQ0a +6z7VVaJeQPmrKQUGi6ts71XjKbAscuwJ+aez14Y= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cezary Rojewski , Takashi Iwai , Sasha Levin Subject: [PATCH 4.19 24/97] ALSA: hda: Fix possible null-ptr-deref when assigning a stream Date: Fri, 24 Nov 2023 17:49:57 +0000 Message-ID: <20231124171935.035561415@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20231124171934.122298957@linuxfoundation.org> References: <20231124171934.122298957@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cezary Rojewski [ 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 Link: https://lore.kernel.org/r/20231006102857.749143-2-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/hda/hdac_stream.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sound/hda/hdac_stream.c b/sound/hda/hdac_stream.c index eee422390d8e2..2569f82b6fa02 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) -- 2.42.0