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 36F82611A for ; Mon, 28 Aug 2023 10:41:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD97AC433C7; Mon, 28 Aug 2023 10:41:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1693219318; bh=kzgVQzeWszVhHHLjIpy6sNxFjSs2zVQXSaa9aq+9AoU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yJ+OvAkoycBjrFwkvJZ6KtwmBYC35PHCL8TKxKTBNaR5Bq2XWh9kZWwLQ/Lu5einn ox3LGaGZAt9zGbFMqocS7Hd8545XIbgyUlJbUtcdM1QGbBmz5k7oHjN7QsUjmH257j 2x0dFhlS2WaD4cop74x65/nyEIxYwZp7+a2PRhw0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Colin Ian King , Takashi Iwai Subject: [PATCH 5.4 151/158] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it Date: Mon, 28 Aug 2023 12:14:08 +0200 Message-ID: <20230828101202.794821211@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828101157.322319621@linuxfoundation.org> References: <20230828101157.322319621@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Colin Ian King commit 011b559be832194f992f73d6c0d5485f5925a10b upstream. Pointer substream is being dereferenced on the assignment of pointer card before substream is being null checked with the macro PCM_RUNTIME_CHECK. Although PCM_RUNTIME_CHECK calls BUG_ON, it still is useful to perform the the pointer check before card is assigned. Fixes: d4cfb30fce03 ("ALSA: pcm: Set per-card upper limit of PCM buffer allocations") Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20220424205945.1372247-1-colin.i.king@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -401,7 +401,6 @@ EXPORT_SYMBOL(snd_pcm_lib_malloc_pages); */ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) { - struct snd_card *card = substream->pcm->card; struct snd_pcm_runtime *runtime; if (PCM_RUNTIME_CHECK(substream)) @@ -410,6 +409,8 @@ int snd_pcm_lib_free_pages(struct snd_pc if (runtime->dma_area == NULL) return 0; if (runtime->dma_buffer_p != &substream->dma_buffer) { + struct snd_card *card = substream->pcm->card; + /* it's a newly allocated buffer. release it now. */ do_free_pages(card, runtime->dma_buffer_p); kfree(runtime->dma_buffer_p);