From patchwork Thu Jun 15 02:17:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Hui X-Patchwork-Id: 693282 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 14F39EB64D9 for ; Thu, 15 Jun 2023 08:18:37 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8695B852; Thu, 15 Jun 2023 10:17:44 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8695B852 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1686817114; bh=FMS1zw3tqC5fMhNPW68xPLqvvFgaZSVPXaOQEsTuvl8=; h=From:To:Cc:Subject:Date:List-Id:List-Archive:List-Help:List-Owner: List-Post:List-Subscribe:List-Unsubscribe:From; b=A+XYHa7io6rMkG7m3lgt8cE+tq9py36YHFxhYFtTAKEwCeGQoM8Vgq2WevzKsmqj2 u67QLQoRYqp49DV3VipUZqKBAKyvOQoyhkSgl2lLK9ZBsZUt7hv3bMo2iNNQpn41Zt zm3bIsKPYgXADy9rY0ERNRkmPi0gVeJS6upjQQwc= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 42282F805A8; Thu, 15 Jun 2023 10:16:33 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id A0919F80589; Thu, 15 Jun 2023 10:16:32 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4A7C4F80149; Thu, 15 Jun 2023 04:17:48 +0200 (CEST) Received: from mail.nfschina.com (unknown [42.101.60.195]) by alsa1.perex.cz (Postfix) with SMTP id CB151F800ED for ; Thu, 15 Jun 2023 04:17:40 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz CB151F800ED Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPA id A9E97603087E5; Thu, 15 Jun 2023 10:17:33 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: Jaroslav Kysela , Takashi Iwai Cc: Arnd Bergmann , maciej.szmigiero@oracle.com, yangyingliang@huawei.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Su Hui Subject: [PATCH] ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer Date: Thu, 15 Jun 2023 10:17:32 +0800 Message-Id: <20230615021732.1972194-1-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-MailFrom: suhui@nfschina.com X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1 Message-ID-Hash: EFZSJAKVN5CM4Y6MF4IYPSQWVKY7PW4W X-Message-ID-Hash: EFZSJAKVN5CM4Y6MF4IYPSQWVKY7PW4W X-Mailman-Approved-At: Thu, 15 Jun 2023 08:14:46 +0000 X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: smatch error: sound/pci/ac97/ac97_codec.c:2354 snd_ac97_mixer() error: we previously assumed 'rac97' could be null (see line 2072) remove redundant assignment, return error if rac97 is NULL. Fixes: da3cec35dd3c ("ALSA: Kill snd_assert() in sound/pci/*") Signed-off-by: Su Hui --- sound/pci/ac97/ac97_codec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index 9afc5906d662..80a65b8ad7b9 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -2069,8 +2069,8 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, .dev_disconnect = snd_ac97_dev_disconnect, }; - if (rac97) - *rac97 = NULL; + if (!rac97) + return -EINVAL; if (snd_BUG_ON(!bus || !template)) return -EINVAL; if (snd_BUG_ON(template->num >= 4))