Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2141812iof; Tue, 7 Jun 2022 21:08:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwGQ5yNBd9Gk21wMU45wF69Lr00yOfhxyJKQIpuAkbp2VdB0Q8FomGWSM6UOAtSz4Ehnaok X-Received: by 2002:a63:4514:0:b0:3fc:20d2:2e74 with SMTP id s20-20020a634514000000b003fc20d22e74mr28525237pga.623.1654661327193; Tue, 07 Jun 2022 21:08:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661327; cv=none; d=google.com; s=arc-20160816; b=mw9BnE6A7+aY+zBVrPJtUEqTplmcVv7Qcnzk9mIUjoPXgEzs3rv/QD8Takpy+pGj1y pZfZqYVLv2u3VMybFYv80oYF7yMxEcnPqzZizAi7pq9ZDDrfH0l5qXR80puIxXmOOuMV azooHZgDNZhDt95o/Jx8RLKA6cQyN0/4lTc6d09kzO8a4bdQInuM+29mfw48JnOjpjcK 49UkV6QIrtHQbr5yt/hn1MOxFGXDswNSvUuMS7bC/MpPdDkWCkmSdZ2uDEk0+RTPuLig CuOFxEuoz5OHsWdG6U3Z78qLo6gDN8CvJEU+gNKYvr4AthPyJxR/X7kE6WNUbzDh+Lai 7OwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PDmvDcF7f53eGGcN32mWe/KwhXMOxznXsv0oyfwWvcY=; b=hf1oZ6JhoerGSKVJbJ9IQAw2qM2pIdLgP9wMaSt1qFcqwPfYW9Mxys5TzK0rUSUPyU SCj2FcvnuN0WRydg96gGZpAimuOpT0JYnyaEATW9mhvmiyWg4VR5YOEsSx2op0K3Px0c bDnKAwMtGuqdqAeiEh8gTmZUnCrIwq9lyQSRkwsLNEbUvDptfeJoBOAYQreMv256NYqm 4jS331OQAySzITNwiP8dWwLe8XHdkTteC5rEwR0i3G1XMJ3AUc+yHnqP0Zo5vcpp8Se+ 8Y7Q17xhwX1LDs02+RdcV3+P6XGsV+7VVb0hPRcfLE6xQBkG8JFr6vUpwqhknY/UFOWQ XECg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DPhpahdB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c12-20020a6566cc000000b003fac9dc870asi27523733pgw.97.2022.06.07.21.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:08:47 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=DPhpahdB; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0949B261CD7; Tue, 7 Jun 2022 20:40:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347717AbiFGRkC (ORCPT + 99 others); Tue, 7 Jun 2022 13:40:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39762 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347404AbiFGRan (ORCPT ); Tue, 7 Jun 2022 13:30:43 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 317BC1109BA; Tue, 7 Jun 2022 10:26:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 71310CE21CD; Tue, 7 Jun 2022 17:26:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56FDDC385A5; Tue, 7 Jun 2022 17:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622793; bh=uD3kUOkQq+jybqex1hsntI82/ulhgLwlE89synK6EKA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DPhpahdBratiuYK3akUEUGixozf9Zcb0sTGcYXloVu/hgPbyzY0C6cD9p7paYL/BP oS8m78/gFSC9kJ4TRj8/OFt6Yf1wHH8QyzI08BnqZnRoKLi6ZgmsHANrobeLG9xxB/ 2AfQSAU7kneuKlckHKAepfm+Z3BvYbdK9a/dLZkg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Takashi Iwai , Sasha Levin Subject: [PATCH 5.10 158/452] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it Date: Tue, 7 Jun 2022 19:00:15 +0200 Message-Id: <20220607164913.268195102@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 011b559be832194f992f73d6c0d5485f5925a10b ] 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: Sasha Levin --- sound/core/pcm_memory.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/pcm_memory.c b/sound/core/pcm_memory.c index a9a0d74f3165..191883842a35 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -434,7 +434,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)) @@ -443,6 +442,8 @@ int snd_pcm_lib_free_pages(struct snd_pcm_substream *substream) 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); -- 2.35.1