Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2511423rdb; Fri, 8 Dec 2023 10:07:51 -0800 (PST) X-Google-Smtp-Source: AGHT+IEFg3iuC7ROD47on8HURg81H1OlTrmTzBQFtTBMA0oHelIFDm3P3mTUm+z1qSauCxKKSa0r X-Received: by 2002:a17:902:7c8c:b0:1d0:6ffd:f230 with SMTP id y12-20020a1709027c8c00b001d06ffdf230mr423721pll.134.1702058871086; Fri, 08 Dec 2023 10:07:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702058871; cv=none; d=google.com; s=arc-20160816; b=QSRxXPeK85iEkxU9ovbJzA1bX8BmWesU0mu9EFZF0jxP+X8+6BcdAn3XsyfC9jplmI ojkEQvtbzkjB7TteFcaTLA3+eZX1dBMUb7JMLlWHcoJ9fESr69Nmlk+sOyHlkNJ5L1ph 6ABtm4gDtQE4TH2lN7Y0FZ94cqMArHCCb4Oe1Bhp1K9zKtkmb16xkI7pAS8B2VP0xHVQ TGgb+0HWfrzUNaZvBP8a9Kx+SdE35vmpLeuyPJepcemzlcr40EnFaJ99u2yzJ5hwLlwq gyKmJm6mX8FW+rBOxh9AcZ7eT2Bo8W13ylb9otPbnVnHnFtP24mP05r6iuGSXuFYialX Hw7g== 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=GwdFWdHWS8T6Tv/kkwDGE6QDkJnV1E1TtDNiOi3nQ5o=; fh=AtUyipZqf9Wt3VmKECtwTscIVbxtj0bqEzvKFfEmcRc=; b=xWB5uLOu43965EiTOqXO8AOWLwMgcAIDTEqtDJf/jkVnWGJfEHlAd/J2eftEFb2DRF XvlavTGl4ASK7rpCWFFdVOMN+3a8FL2oY1aKyjn3G7Bbs2lplWU/NBLqGOdeNb721VIx fwaF2u+OxZyuP8AlCeiM1G099jM3xiouuEsEEiC4Geas1ISWwkIl6g33l5Wcm8iTDaFu PorGWLaNZgzDPeGxR75D/ZkDePg9YoK1J0TrBD/jRnCTQv4I6hayFN/g0+TbWxv7Ke1T Rn57kUk0ZXdFawGpQiLgDB3TQM9wi2zvR7Yw+M47RdbDNgLmtg6iGmf6DfMbZEfkBdrN cIaQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id o12-20020a170902bccc00b001cfb4d36d44si1882303pls.64.2023.12.08.10.07.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 10:07:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=irl.hu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 3BB1180FDDFB; Fri, 8 Dec 2023 10:07:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574499AbjLHSHk (ORCPT + 99 others); Fri, 8 Dec 2023 13:07:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235941AbjLHSHj (ORCPT ); Fri, 8 Dec 2023 13:07:39 -0500 Received: from irl.hu (irl.hu [95.85.9.111]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 472C51729; Fri, 8 Dec 2023 10:07:45 -0800 (PST) Received: from fedori.lan (51b690cd.dsl.pool.telekom.hu [::ffff:81.182.144.205]) (AUTH: CRAM-MD5 soyer@irl.hu, ) by irl.hu with ESMTPSA id 00000000000719EC.0000000065735B6F.0011CB93; Fri, 08 Dec 2023 19:07:43 +0100 From: Gergo Koteles To: Shenghao Ding , Kevin Lu , Baojun Xu , Jaroslav Kysela , Takashi Iwai Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Gergo Koteles , stable@vger.kernel.org Subject: [PATCH v2] ALSA: hda/tas2781: leave hda_component in usable state Date: Fri, 8 Dec 2023 19:06:49 +0100 Message-ID: X-Mailer: git-send-email 2.43.0 Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Mime-Autoconverted: from 8bit to 7bit by courier 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 08 Dec 2023 10:07:49 -0800 (PST) Unloading then loading the module causes a NULL ponter dereference. The hda_unbind zeroes the hda_component, later the hda_bind tries to dereference the codec field. The hda_component is only initialized once by tas2781_generic_fixup. Set only previously modified fields to NULL. BUG: kernel NULL pointer dereference, address: 0000000000000322 Call Trace: ? __die+0x23/0x70 ? page_fault_oops+0x171/0x4e0 ? exc_page_fault+0x7f/0x180 ? asm_exc_page_fault+0x26/0x30 ? tas2781_hda_bind+0x59/0x140 [snd_hda_scodec_tas2781_i2c] component_bind_all+0xf3/0x240 try_to_bring_up_aggregate_device+0x1c3/0x270 __component_add+0xbc/0x1a0 tas2781_hda_i2c_probe+0x289/0x3a0 [snd_hda_scodec_tas2781_i2c] i2c_device_probe+0x136/0x2e0 Fixes: 5be27f1e3ec9 ("ALSA: hda/tas2781: Add tas2781 HDA driver") CC: stable@vger.kernel.org Signed-off-by: Gergo Koteles --- sound/pci/hda/tas2781_hda_i2c.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sound/pci/hda/tas2781_hda_i2c.c b/sound/pci/hda/tas2781_hda_i2c.c index fb802802939e..7dfa8aeb5fcc 100644 --- a/sound/pci/hda/tas2781_hda_i2c.c +++ b/sound/pci/hda/tas2781_hda_i2c.c @@ -612,9 +612,13 @@ static void tas2781_hda_unbind(struct device *dev, { struct tasdevice_priv *tas_priv = dev_get_drvdata(dev); struct hda_component *comps = master_data; + comps = &comps[tas_priv->index]; - if (comps[tas_priv->index].dev == dev) - memset(&comps[tas_priv->index], 0, sizeof(*comps)); + if (comps->dev == dev) { + comps->dev = NULL; + strscpy(comps->name, "", sizeof(comps->name)); + comps->playback_hook = NULL; + } tasdevice_config_info_remove(tas_priv); tasdevice_dsp_remove(tas_priv); base-commit: ffc253263a1375a65fa6c9f62a893e9767fbebfa -- 2.43.0