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 8B26C33EC for ; Mon, 16 Jan 2023 16:01:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0C0F0C433EF; Mon, 16 Jan 2023 16:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673884877; bh=AdGuGlY91n6XhXYPhCqj4AtSSr6BJKNwfdIJhNi92cM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miT2HV6jslRVAkmOTI4Xu4Pzlle9J761ynhDmpfgipnM/AWP3Mh78xfDmGcxL0+2F ybQLu4lMfyGfbHn+W/UPCYwvQiAObzMth5TEXtun4Q6lItxKWd++plB70s8+b2odam BvbbvaX3gMbFRuhdEzjvIbZyMu/2pAeZDDzEVPrg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, coverity-bot , Jaroslav Kysela , Takashi Iwai , Sasha Levin Subject: [PATCH 6.1 174/183] ALSA: usb-audio: Fix possible NULL pointer dereference in snd_usb_pcm_has_fixed_rate() Date: Mon, 16 Jan 2023 16:51:37 +0100 Message-Id: <20230116154810.655727238@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154803.321528435@linuxfoundation.org> References: <20230116154803.321528435@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Jaroslav Kysela [ Upstream commit 92a9c0ad86d47ff4cce899012e355c400f02cfb8 ] The subs function argument may be NULL, so do not use it before the NULL check. Fixes: 291e9da91403 ("ALSA: usb-audio: Always initialize fixed_rate in snd_usb_find_implicit_fb_sync_format()") Reported-by: coverity-bot Link: https://lore.kernel.org/alsa-devel/202301121424.4A79A485@keescook/ Signed-off-by: Jaroslav Kysela Link: https://lore.kernel.org/r/20230113085311.623325-1-perex@perex.cz Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/usb/pcm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 29838000eee0..2c5765cbed2d 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c @@ -160,11 +160,12 @@ find_substream_format(struct snd_usb_substream *subs, bool snd_usb_pcm_has_fixed_rate(struct snd_usb_substream *subs) { const struct audioformat *fp; - struct snd_usb_audio *chip = subs->stream->chip; + struct snd_usb_audio *chip; int rate = -1; if (!subs) return false; + chip = subs->stream->chip; if (!(chip->quirk_flags & QUIRK_FLAG_FIXED_RATE)) return false; list_for_each_entry(fp, &subs->fmt_list, list) { -- 2.35.1