Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3614981pxb; Tue, 19 Apr 2022 06:38:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx1YJJKZmVp2uI6DhFZKZmo5aVQDTP+W1CfC2Zqvoyq1C8V8/0eBEUf1T7TsTf8aU0VFp/v X-Received: by 2002:a17:907:8a15:b0:6e8:d28e:83d7 with SMTP id sc21-20020a1709078a1500b006e8d28e83d7mr12977599ejc.640.1650375529013; Tue, 19 Apr 2022 06:38:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650375529; cv=none; d=google.com; s=arc-20160816; b=mvAqH/63Fyir2TI9OKvJUfgB337SoipvZItoq2umwP2nzG0bp2tvxmySkXx5mGHZmt sZbsB+9GRJNVzlXUe4ULde7K9XQXHH+fG3fEq1xvIpzkKSLoPWB5ET+nXVOXy+mI7yYJ J2hj37wBhQqo7CG7dlWbKiOOMOL6DxERE6G/y3WPkWC8owASnUXotB9zDaiYI43S/Ric ytZBpLnWLeJOH8Qd5PnQMVylT2DpozcB3Yb3UjhLeJszBmehH57xeiDPwOk79s5uSi2k 43jeXA/wtRn4DVNfwtEkq4wAYAziWz7DytvMj1hWMBD9gAHzH2ahcW/o2pIbUS5mIxn9 Qoqg== 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=G4SkUGoCSducwC9t7AiddwlirT+R9t/j1z/0EcaZMB0=; b=bbpOnEhUPB01nR3wYFBkXjuMcuKzUatmNL2zdHkMNCynj8RW6vz9CUWtU6fVJVZ54t vDCad6xJg9F/GrhOGSHA/mC7zPr3qV/Nfmr3iDWDFNG3w6tH+uAiK9yJqdLW3lRIbrzs jtWK5AUhzn+1TzFSq4MbFM5AQDZHK/oJZQVMb4SIdirWYvXQuQ+UUdVPT6tFUrJ2YaqU EUSKmZCUFpNfw3oNDcuIYVVgcl75dQpz/pTkBbOJqWliH6yMQJuDwoVARzzyzgREpajp PSyb9QhNdE+Hfw2+y3/3hyTnHiWrl//yDcrGpCCS0kEPZxE+bfoDCZ52vAG8YZc/eYT7 ZdQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BEGAlTBU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p5-20020a170906604500b006e85953eb12si8680443ejj.347.2022.04.19.06.38.23; Tue, 19 Apr 2022 06:38:48 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BEGAlTBU; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235788AbiDRNf3 (ORCPT + 99 others); Mon, 18 Apr 2022 09:35:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242639AbiDRNJR (ORCPT ); Mon, 18 Apr 2022 09:09:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 599813614E; Mon, 18 Apr 2022 05:48:46 -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 7AD9460FB6; Mon, 18 Apr 2022 12:48:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7338FC385A1; Mon, 18 Apr 2022 12:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650286124; bh=6118wY5SUqvaOGFyKq6KoocM37LhFJT1VLYB+36B0Ig=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BEGAlTBUDQB6DUBfUPay87sPa3P5Q/NCcbZi8qtUgjVHcI+TDyGQQ7aE3fWFf9INs /3kG9gP9IOCB5wCFj/U/kvu+gLHvsO675jVHLTyM7sbGuDDhDFVxrSTlYODfmGSmBi DR+6L2aqBPcEUCzgs5BcsAgdDVyR+JQsVINxCzzE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Takashi Iwai Subject: [PATCH 4.14 035/284] ALSA: cs4236: fix an incorrect NULL check on list iterator Date: Mon, 18 Apr 2022 14:10:16 +0200 Message-Id: <20220418121211.693125219@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121210.689577360@linuxfoundation.org> References: <20220418121210.689577360@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 @@ -559,7 +559,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)) @@ -575,9 +575,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)