Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2173899iof; Tue, 7 Jun 2022 22:10:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUxJyAArrLU+ou7QtGKzIQWcrmRFFx+9m1Judic/xGyCu7htxi8OsHn5xhq5nK4EHvxCpx X-Received: by 2002:a17:902:d2d1:b0:167:4c33:d5d3 with SMTP id n17-20020a170902d2d100b001674c33d5d3mr25142931plc.81.1654665029817; Tue, 07 Jun 2022 22:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654665029; cv=none; d=google.com; s=arc-20160816; b=AvZSZ5pY2dtIyrvUDi7goxOHyC8WACMCAbrqlHMpbdzzRvQjZtAftTBmlH9Rogs16+ 03cTvxG18QUXYQxcqZKEbiIss1aPQeWY2FGIzpXrKuISYlONA8uxvhLP6wkr2bcrx6OH kdkx8U+JdDyOwoB8Yb5GyfulDdq8Nbfh280Y6tIG5TpIA1V2fho0wTBsrjDDTChpoiH0 7VQHUGZdidtAORqvr8yzrFsLZns9zARVzbKz/kBAfY1jSpeeOcUcBuuRPk4YMoH+AFS3 guLkrDwIhkkRrdm31mX3Ltr6cf22NXFhboCL4lm++D371jh6AKr/XjYDsICbHRigYKre m3gA== 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=A1nOXneS/o6OamUUYkEkP+ExVzMwVjL17aiPsBCBYRY=; b=JaruunZsxAa0G0VRXnjvnPYxvcyk3zq1ePQU/vd8HyoZcuNA2qUM5s6emGjxT/yoSe C1PIHCyVvKVsX0Ad60FfKIop1etTFbPqlsSkjBl+S7Z9BxV1+i4c8XS6Qbpct2DuGe0G VvWqaaYdhXfJWub06hf1+XLKdYR1HnZSG/6Z7ts0A/sSbGHXfwi7/mDA0FSyJyTiHdS9 Jo7iWlK59ZZOLiKY1RocvRTqOPZ0WM0lWUsv4cyZN+w0xTS69R82C9kD9GsQqEczFeVI h55z5lYgzih1KQ66hHKuFbctLFjflah0VhFMQrNpAWtLAv1vr4eJawp9yUFoA8mKw6x5 YtMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FBT/phw+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q1-20020a63ae01000000b003c6709779a9si27803177pgf.295.2022.06.07.22.10.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="FBT/phw+"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 A9659522F4; Tue, 7 Jun 2022 21:41:10 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378743AbiFGWif (ORCPT + 99 others); Tue, 7 Jun 2022 18:38:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378941AbiFGVZK (ORCPT ); Tue, 7 Jun 2022 17:25:10 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DF0227CEE; Tue, 7 Jun 2022 12:01:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id E978E61787; Tue, 7 Jun 2022 19:01:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F4091C385A2; Tue, 7 Jun 2022 19:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628484; bh=+hczqrVV9QRUroM1CK7I7IRBPGHFmeEUds3FThURv7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FBT/phw+i57k7PnKxod6J7JDPPHmpM2LkhZ0hGwt3sV7snAfWuNrEFmOQKjqdkCAV d35Qc4X5LawFk4ALHnvVqMz17FkT3h54th7FuW6ovSYJx4BJYd2wnBG8ciDq+AAqD3 lN2ofmbQAI3iwJfVXTy7qC2QJoazLlUMfP1ihdoY= 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.18 346/879] ALSA: pcm: Check for null pointer of pointer substream before dereferencing it Date: Tue, 7 Jun 2022 18:57:44 +0200 Message-Id: <20220607165012.904143979@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 8848d2f3160d..b8296b6eb2c1 100644 --- a/sound/core/pcm_memory.c +++ b/sound/core/pcm_memory.c @@ -453,7 +453,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)) @@ -462,6 +461,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