Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2398860imb; Mon, 4 Mar 2019 04:16:58 -0800 (PST) X-Google-Smtp-Source: APXvYqyfin7Ccb6DiMRTnnX4ernVTkZ2Fy4JtZ9Vc9vqFRRkceMTtGufbBHOR2Y7I1BNd7LcDpcl X-Received: by 2002:a63:440d:: with SMTP id r13mr18169776pga.5.1551701818463; Mon, 04 Mar 2019 04:16:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551701818; cv=none; d=google.com; s=arc-20160816; b=XMMWQT25QGcdvpZ4F781iiq1tXiIqH2lvzlBdY8mWAint4nE8iUOFp2mwaGWcf4cKt w2XMTVFXq3ZbuaTnFsLunpL/+v8fsJIpPMzicmtNnOPou4I5Bi6wYqNGkO8LoRnCj4WM ks33Hfbn9OWedAG1NBHcQHvmVLnrXSxNqwrXfJyhVkm/UH8puU6/8JvoZhX+onIR37FU c1SV+HYBjTuq19Sw1Ogn1X5mgELUEcxflG5D0w87VsoNADpurTylWKkQ4rB3+aByKtA2 1qAb/54YMWEeNiQIkg+Xe2qFSxDhW71ExNRtQMAgge6ysYZlUrcB5E9SyWy/Ph6ImmxN NRWQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=V3kgIuSWnEvtfqPkX44tTeFC5VFR47wme3mhOcRjuJ0=; b=h1hPZQuev9be7IHGIvpocnEL8JemKIeCAj06aRsso1fWZAZSlFCeV9x0ubbs2fkbcI Ln4hEIzzoOguKvb+FQwxfA43VRs4JA1oYA4QyFcx3qxiNB/wp1mBA/lI1jhUKvV0MSMP qQ9agQmSXU0V2dm1YAPgyVuyOGVxg2CcdBpz3OiFnEwa8vGALUSvsAV7X3G/Rbck8Zc6 EwDRbE474AwtbofzlhVyrUxnHae9WtygTCBgYK3K5Gbgj0qgGq20yFswHfmzevH7mknr I8VgrACe/c5+iA6SQ65p85ZrtOvHEpj+V4F3H/dsS8MXbicLpEoAz18h5ueomI+7I7OS ytUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=wSulFOfe; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q65si5106672pfi.185.2019.03.04.04.16.43; Mon, 04 Mar 2019 04:16:58 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b=wSulFOfe; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726449AbfCDLou (ORCPT + 99 others); Mon, 4 Mar 2019 06:44:50 -0500 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44154 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbfCDLou (ORCPT ); Mon, 4 Mar 2019 06:44:50 -0500 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id x24BiQvX057296; Mon, 4 Mar 2019 05:44:26 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1551699866; bh=V3kgIuSWnEvtfqPkX44tTeFC5VFR47wme3mhOcRjuJ0=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=wSulFOfeZd4hL5M1jIjig3ysJwYczQ30m64fyUzqC/eAx5K8F/7MV8RzMxMAUqgrv I2UVcCWmeaMpSWO4sOQKh5nJKjNZjsE7jkJUn0jlCLK9bgQTJW+Tsfsq2xQiKNi1WN X43eRiDeXThNUtxyhXcHwLKDVVi8uyUxsHeRcGoE= Received: from DFLE112.ent.ti.com (dfle112.ent.ti.com [10.64.6.33]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x24BiQUU105510 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 4 Mar 2019 05:44:26 -0600 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE112.ent.ti.com (10.64.6.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Mon, 4 Mar 2019 05:44:24 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Mon, 4 Mar 2019 05:44:24 -0600 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x24BiMPt017639; Mon, 4 Mar 2019 05:44:23 -0600 Subject: Re: [PATCH v2] ASoC: tlv320aic3x: fix reset gpio reference counting To: Philipp Puschmann , , CC: , , , References: <20190227151733.4419-1-philipp.puschmann@emlix.com> From: Peter Ujfalusi Message-ID: <860b91b9-0131-323b-fa62-f37ff2c9d23b@ti.com> Date: Mon, 4 Mar 2019 13:45:00 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 In-Reply-To: <20190227151733.4419-1-philipp.puschmann@emlix.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/02/2019 17.17, Philipp Puschmann wrote: > 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. Reviewed-by: Peter Ujfalusi > > Signed-off-by: Philipp Puschmann > --- > Changes in v2: Fix typo in title tlv320aix3x -> tlv320aic3x > > 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 6aa0edf8c5ef..cea3ebecdb12 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); > - Péter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki