From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFAA4C71145 for ; Thu, 24 Aug 2023 08:05:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235729AbjHXIFC (ORCPT ); Thu, 24 Aug 2023 04:05:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233510AbjHXIE2 (ORCPT ); Thu, 24 Aug 2023 04:04:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB59819A1; Thu, 24 Aug 2023 01:03:38 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2C7722214B; Thu, 24 Aug 2023 08:02:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1692864165; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9OiPVHqqVfJrxrNZ8ndJG8ZGc9PmvqzmtT2i2dfcnAQ=; b=Gvwnhig+SBDAc1PYubpSurfDgIaeqmgEyBccf9zKzfaLSccRCVDuszW/nPqV8AbhB6F5Kh TIt3So1DUFONHRQJGC/2VgzykZ60eJJ286pGXGE04WhCAI0R49nnbLE86XEPwuBK/QXfJ5 yJWYGRpRDqi84/uOPYS589yMFfJcRU0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1692864165; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9OiPVHqqVfJrxrNZ8ndJG8ZGc9PmvqzmtT2i2dfcnAQ=; b=jZqh7G0OWXfcGuzeG/fH/O81ELED3/6cmEyaXF1c9lcgooTuPeV9dEIb0twnUcS823nQMB lfuUufnpF+zeq8CA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id E2E63139BC; Thu, 24 Aug 2023 08:02:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id HNbINaQO52QZMgAAMHmgww (envelope-from ); Thu, 24 Aug 2023 08:02:44 +0000 Date: Thu, 24 Aug 2023 10:02:44 +0200 Message-ID: <87cyzcc1gb.wl-tiwai@suse.de> From: Takashi Iwai To: Su Hui Cc: Christophe JAILLET , perex@perex.cz, tiwai@suse.com, arnd@arndb.de, robert.jarzmik@free.fr, yangyingliang@huawei.com, maciej.szmigiero@oracle.com, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] ALSA: ac97: Fix possible error value of *rac97 In-Reply-To: References: <20230823025212.1000961-1-suhui@nfschina.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Aug 2023 19:20:49 +0200, Christophe JAILLET wrote: > > Le 23/08/2023 à 04:52, Su Hui a écrit : > > Before committing 79597c8bf64c, *rac97 always be NULL if there is > > an error. When error happens, make sure *rac97 is NULL is safer. > > > > For examble, in snd_vortex_mixer(): > > err = snd_ac97_mixer(pbus, &ac97, &vortex->codec); > > vortex->isquad = ((vortex->codec == NULL) ? > > 0 : (vortex->codec->ext_id&0x80)); > > If error happened but vortex->codec isn't NULL, this may cause some > > problems. > > > > Move the judgement order to be clearer and better. > > > > Fixes: 79597c8bf64c ("ALSA: ac97: Fix possible NULL dereference in snd_ac97_mixer") > > Suggested-by: Christophe JAILLET > > Signed-off-by: Su Hui > > --- > > sound/pci/ac97/ac97_codec.c | 5 ++--- > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c > > index 80a65b8ad7b9..25f93e56cfc7 100644 > > --- a/sound/pci/ac97/ac97_codec.c > > +++ b/sound/pci/ac97/ac97_codec.c > > @@ -2069,10 +2069,9 @@ int snd_ac97_mixer(struct snd_ac97_bus *bus, struct snd_ac97_template *template, > > .dev_disconnect = snd_ac97_dev_disconnect, > > }; > > - if (!rac97) > > - return -EINVAL; > > - if (snd_BUG_ON(!bus || !template)) > > + if (snd_BUG_ON(!bus || !template || !rac97)) > > return -EINVAL; > > + *rac97 = NULL; > > if (snd_BUG_ON(template->num >= 4)) > > return -EINVAL; > > if (bus->codec[template->num]) > > FWIW, > > Acked-by: Christophe JAILLET Applied now, thanks. Takashi