Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1178438yba; Thu, 9 May 2019 12:03:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzHLg5R9FRkm+MimyAUHtxMMZdaxulr41PUTASaAd4glmEwM97WrBj0Ai1g6egQ7SM2vfOb X-Received: by 2002:a63:d252:: with SMTP id t18mr7963913pgi.131.1557428629515; Thu, 09 May 2019 12:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557428629; cv=none; d=google.com; s=arc-20160816; b=mPPtUPZf/TGvwZSB4Boa3qL5J/jsnUvqZOBj85wKkR2Ha5HT5q4wUZWNMymwsqmQAc L1yHGXRHoANENOTsMzzNdLB8KVU7fWy+8/eL3PWClKSK/R2BG50X/h+5PxA6Ck3Uxrsb Zvx5gD2GI+poxTgPPTkqWm8AqTdv4AgjvlcgCfby6OrjY1vTZDzfa220JSaQmQQ5t1h8 IFs6D6VzDyu80G4cVEHgwwnoOarHkAuayiVn636nujP2sg1DNFrzw7kY6RD9DN83CC6m wvBJrUHEa7OrQNhP0W3sI98RhAM+vpvcRaGFi7nC6CKMwFqISaR+5CNLkIf3eF0FXjCd 5mUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/bMTV6odQOjQHTaU/mi0ZgvlusKcvFKl0vdL2heyHmI=; b=F4RGTSmt6R9yIVyNKdMeDOEKYDxwWUDHAVqwKMAXsTnMbPBMBU96D7y4Hr7L85nb8Y ft1ohrJQP5zTChglXh9qM/x8dTcv/CeBrgEtiXyZ2XIHHfMKcVlvofH+0FBSv4ArQKHp ZAMrnMW6ZYrq/K1EvdH/RNxqrEI3EQSLm1YCTOJ1io5gVTk4AhNJvtOBQCgZfcpzTuB8 cdMxZfcMNDopLbPToQqMj4ioBORCVPSflTLMOvBKJqQzNIhL7IV2Pn+zsChgPBOzRgbL JnUZkY1GenoHdLtz17qfxi2mnr4d3l+U2q22rQs0M3Y7TFYzdyGr788OAiLVfYlda1EC 7ljg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nQRz+oBv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h62si4620186pfj.91.2019.05.09.12.03.32; Thu, 09 May 2019 12:03:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nQRz+oBv; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728298AbfEITBE (ORCPT + 99 others); Thu, 9 May 2019 15:01:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:44810 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727913AbfEISvK (ORCPT ); Thu, 9 May 2019 14:51:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4994F20578; Thu, 9 May 2019 18:51:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427869; bh=Kwg4yaFslhIutCJAYEKJrQO/fw8f/IpuiNsONfVnzeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nQRz+oBv1flIRBfsYS4v8DzAVu1QsqwcFpE2d6PTUfeRfu7MuUH0LfhDE2meM2x7f rqzI/08sT0t2x6nkGEB8eiJc1t8WWwTYrQ7aBjETdr+ncFhKWH1GY3Gp7mh2UpyCWt jg3w8cFqYj+x19MC82uADEeaSFeE2CPcQrbI65SQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Philipp Puschmann , Mark Brown , Sasha Levin Subject: [PATCH 5.0 08/95] ASoC: tlv320aic3x: fix reset gpio reference counting Date: Thu, 9 May 2019 20:41:25 +0200 Message-Id: <20190509181309.912685562@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181309.180685671@linuxfoundation.org> References: <20190509181309.180685671@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 82ad759143ed77673db0d93d53c1cde7b99917ee ] This patch fixes a bug that prevents freeing the reset gpio on unloading the module. aic3x_i2c_probe is called when loading the module and it calls list_add with a probably uninitialized list entry aic3x->list (next = prev = NULL)). So even if list_del is called it does nothing and in the end the gpio_reset is not freed. Then a repeated module probing fails silently because gpio_request fails. When moving INIT_LIST_HEAD to aic3x_i2c_probe we also have to move list_del to aic3x_i2c_remove because aic3x_remove may be called multiple times without aic3x_i2c_remove being called which leads to a NULL pointer dereference. Signed-off-by: Philipp Puschmann Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/tlv320aic3x.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6aa0edf8c5ef9..cea3ebecdb12b 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c @@ -1609,7 +1609,6 @@ static int aic3x_probe(struct snd_soc_component *component) struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int ret, i; - INIT_LIST_HEAD(&aic3x->list); aic3x->component = component; for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { @@ -1692,7 +1691,6 @@ static void aic3x_remove(struct snd_soc_component *component) struct aic3x_priv *aic3x = snd_soc_component_get_drvdata(component); int i; - list_del(&aic3x->list); for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) regulator_unregister_notifier(aic3x->supplies[i].consumer, &aic3x->disable_nb[i].nb); @@ -1890,6 +1888,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, if (ret != 0) goto err_gpio; + INIT_LIST_HEAD(&aic3x->list); list_add(&aic3x->list, &reset_list); return 0; @@ -1906,6 +1905,8 @@ static int aic3x_i2c_remove(struct i2c_client *client) { struct aic3x_priv *aic3x = i2c_get_clientdata(client); + list_del(&aic3x->list); + if (gpio_is_valid(aic3x->gpio_reset) && !aic3x_is_shared_reset(aic3x)) { gpio_set_value(aic3x->gpio_reset, 0); -- 2.20.1