Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp601202pxb; Tue, 5 Apr 2022 15:33:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqLZ5yaBLal3tK8oHaeQvxgF3spjv5dc15UfnE8lUnIY/P+Wk33hmUDPzuGXb/QmqblmKB X-Received: by 2002:a17:902:8e82:b0:151:6f68:7088 with SMTP id bg2-20020a1709028e8200b001516f687088mr5736039plb.11.1649198002869; Tue, 05 Apr 2022 15:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649198002; cv=none; d=google.com; s=arc-20160816; b=T9RyseOHl7n24rWTsBWbg0PXH0RKNCUqXBTuz1Ipo3HkGhsTUBD99wvVZrtsR5jt1d Mpl6GjD3xTQLBqQf0SZqCol89evS3nEZxTks0iiespzWOQAJmF6s3e2J4Kmd051BZIDs ZKMxfR0zsI40Pvnfw1406YmRLZ11A7qkPC7uRf7LRsABnEK31TCTb5Q5nXayucU5s6rE 6LISA/+Jrnh5MWXNA6EVc3ONcwZXZrnpMwtBx/vQXGdH/SB/QqDO+YhzIhvCx2vtMb0e sRPTCP/UOUIxCJxYkVdopuu6Esi+AHHKH6o9TpFUXxBx4ePL8dFnpMSc1q875rtFX41V ATmw== 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=Fr0CcZ6fX7TNU4vtRMAsGfDXzJrAOehJr6uh5/QtrdQ=; b=dwGN6UnSUhkTJgLeTe4t5DfQmCoYZ6ZxoYIw50wP/m8Ah2/pIyD7R5nGRnnvHt5hi4 0CvyCCEf3lm1y2F8w323Vuna5hqvaNGKpbGMssEUiTjDy5Ytmu6hj+MEzdDduQlnZYjB 3Dxa2oa9vCkxKedZpT2SzHuWhI7S6K/G9HJnspS1Ax2t0PQm6LzsPvmjJs/AsCPRmPRR l3gBDTXd+iRdM+r1DXM6SA1ngsbG1tGGJBRHnqbc+1l9SKjt3PX532B9kDEqxNNEEjqP z1Y5rbnwmeLAtza3Hlyn5DhOSHhYF+zYV9AJRk2vnvSE8MkwfBSBkTGWZpwatge5llE4 ow7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wl+d6W84; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id x28-20020a656abc000000b00381f73774fasi15098974pgu.355.2022.04.05.15.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:33:22 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wl+d6W84; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D147A20DB0E; Tue, 5 Apr 2022 15:15:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354323AbiDEOVi (ORCPT + 99 others); Tue, 5 Apr 2022 10:21:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239653AbiDEJeA (ORCPT ); Tue, 5 Apr 2022 05:34:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9931C4; Tue, 5 Apr 2022 02:22:41 -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 85BED6164E; Tue, 5 Apr 2022 09:22:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 976D0C385A0; Tue, 5 Apr 2022 09:22:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150561; bh=wlmFr2b3C5Fy7AKv86kvgZ3YLzVJKOPbSeAkty2RuEU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wl+d6W847q0x9bccY37hvPiun22Lnxu43NMShyNgabXmlaunZhrWae7NpeYpj/yEE kZ5S0nZWFAVGjIc+7Koa+j0Fna5IFrYfauDwE5mSpr1/elN57A4qLEM802x+X3fQ/a cxwChO3zLS2kAaXkmxsj3UbF4Rxc43k2ev5Sw6TM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Takashi Iwai Subject: [PATCH 5.15 099/913] ALSA: cs4236: fix an incorrect NULL check on list iterator Date: Tue, 5 Apr 2022 09:19:21 +0200 Message-Id: <20220405070342.795163469@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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=-2.0 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=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 From: Xiaomeng Tong commit 0112f822f8a6d8039c94e0bc9b264d7ffc5d4704 upstream. The bug is here: err = snd_card_cs423x_pnp(dev, card->private_data, pdev, cdev); The list iterator value 'cdev' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found. To fix the bug, use a new variable 'iter' as the list iterator, while use the original variable 'cdev' as a dedicated pointer to point to the found element. And snd_card_cs423x_pnp() itself has NULL check for cdev. Cc: stable@vger.kernel.org Fixes: c2b73d1458014 ("ALSA: cs4236: cs4232 and cs4236 driver merge to solve PnP BIOS detection") Signed-off-by: Xiaomeng Tong Link: https://lore.kernel.org/r/20220327060822.4735-1-xiam0nd.tong@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/isa/cs423x/cs4236.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/sound/isa/cs423x/cs4236.c +++ b/sound/isa/cs423x/cs4236.c @@ -494,7 +494,7 @@ static int snd_cs423x_pnpbios_detect(str static int dev; int err; struct snd_card *card; - struct pnp_dev *cdev; + struct pnp_dev *cdev, *iter; char cid[PNP_ID_LEN]; if (pnp_device_is_isapnp(pdev)) @@ -510,9 +510,11 @@ static int snd_cs423x_pnpbios_detect(str strcpy(cid, pdev->id[0].id); cid[5] = '1'; cdev = NULL; - list_for_each_entry(cdev, &(pdev->protocol->devices), protocol_list) { - if (!strcmp(cdev->id[0].id, cid)) + list_for_each_entry(iter, &(pdev->protocol->devices), protocol_list) { + if (!strcmp(iter->id[0].id, cid)) { + cdev = iter; break; + } } err = snd_cs423x_card_new(&pdev->dev, dev, &card); if (err < 0)