Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp481001rwd; Wed, 14 Jun 2023 19:57:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5aBDr+kmyxMVVV1w0wH1QlLQN27mfE7vECZB8TGOIUSuot8ovwh8JoB7cBTG84HTl90M/S X-Received: by 2002:a17:907:5ce:b0:978:6e73:e837 with SMTP id wg14-20020a17090705ce00b009786e73e837mr18445041ejb.4.1686797857880; Wed, 14 Jun 2023 19:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686797857; cv=none; d=google.com; s=arc-20160816; b=cFgIeJUtv00AqDr40bFMbeAui/bLUWaAyDEgAPlpF3HBVsXjyCHLZG53YBfE/WWT9I vTG10+jX8eWF3S/kYNPicwPRgzFTYYCStKBnZqYXHsAZdNF45h5Z5W905TdzA7D5/vrk JDt+rZDR5sgneXb0P+NalL93hn5DB/el6Ta2kcWGltvI4H4fRi7XRkoAmO8Vdj0iFOaz OUEVvTBdb2f+VGttrSCIGJby6+lTh7tYYHLbGaaUDM9MgutTg21aVdxhxZP1k/EyDmZR mB3VLm4oFcg6Pf1ZQyGeweXZT7djRZHedR7AytS1cZ7VUQQzs7gHdSE/S5XNSc05MGqI T7gg== 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 :message-id:date:subject:cc:to:from; bh=q5LKI/z7X9CM/Ca/vQUvCotAeT1TcZKv4ATji59Y6o4=; b=xvSAzoIpAHtc+S1hTMhLD69PmAtcaVCgV5UxYlYE1XJCZgE478IUqD0VjzR1KfaOBf suIWK1g6/J2GVTDABxRVaG18bk2pXB8L3usoCkGq0LICCwsi18tnuqO+pWAU8czMn/UB Wbs2NrUSNTt7Wyo3l1SV7hwdFbCDw8lHSAuT4pVFN8ZB3OmYxvQQTVNC03TkkTKLGnCO mlCwF115wT2rCqQrizB+3PnVFg5KkU20D0SYeayS0ac5SdERDX2mfudXSeom/OE8zIgL sSRQp0rF1dtmSSNchOJZjAe6tHUvVIGGo5fEL6/bh3b4L7wLTXGZm2cWS3REeL7zMpI4 HL1g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d20-20020a170906641400b009781494aca8si8783133ejm.725.2023.06.14.19.57.13; Wed, 14 Jun 2023 19:57:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238097AbjFOCSH (ORCPT + 99 others); Wed, 14 Jun 2023 22:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237394AbjFOCSE (ORCPT ); Wed, 14 Jun 2023 22:18:04 -0400 Received: from mail.nfschina.com (unknown [42.101.60.195]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 98B0E26B6; Wed, 14 Jun 2023 19:17:58 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 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)) -- 2.30.2