Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4143969pxk; Tue, 8 Sep 2020 11:46:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyijL9qk6dlEhgwoKMhaJZixDHun1SVX0XR8j6a5a37/++slAjWnwvrUKKkpYFtht2OAANK X-Received: by 2002:a17:906:cf9d:: with SMTP id um29mr27030749ejb.74.1599590789995; Tue, 08 Sep 2020 11:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599590789; cv=none; d=google.com; s=arc-20160816; b=vvcnsRDRfztG4drvgom/+JuYzAMEkdub5i8P3eeKC4A2jvime8An0TORmuxSocgaL7 +iREg51Y4Q/6/RydQw+XeowZxtbdC5w5OHQ8F2vevwQdqUC2JO1MjGbq6rAKOzseoLWn 9tW18R2xmRrwDQxUqtbb2mcJgzRBXHaveICvhMgMneJ2Fgv4aKKxWV98E009vqSJoeL4 hI+GKNrpwwE8OMAtnXhGH+AWUok8KZnUQ/pFphEVH//x57GOQ7UjBekokUKn5IQQ2tMy pJm4xGJuMCbS2/UMZmPsZWP3vUhR7Zhy+ccB6xPDA/vxVlQ8IRqaNn0+A4ux4IV4sQSf YP+w== 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:references:cc:to:from:subject:dkim-signature; bh=nsqPY6o4grvE2pz2lannxuY5WsjPIahg4+RoCYp/mc4=; b=SiX66v1UV+QOeOKvvEC2Z2cJAaWqY8LdZpdF6hnK7NZx6DVCuhZqokk6W0X/vEfv5q LJypviu4ljHAqd0XpVfs+ka7LiwzYuIn7ZO/6SBJsUNv4Om/AbL/Ie5vqqCQMMpBHzwJ M6GD2NuB/Uxfrt7IFuvJ7lV1voakSVLmTiY/5T1g/AGvJRBlYkBKP/EfOvgGJHsnBdPn 825vz5uGQG4ZoU/lEnarm2e6mSPzxkwQnUqD2vEHXZS86+t+E2FZbXGtZ6ARUVAfvgsE av17/Ssdqs3lWi8/i0Cs1ynhqVfbMu5bp0jnTkJNGLa2JvHb4TPXhsh5B5zYugS+hBG/ scmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ia2HCvqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id ds18si13075146ejc.745.2020.09.08.11.46.06; Tue, 08 Sep 2020 11:46:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ia2HCvqT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726714AbgIHSpS (ORCPT + 99 others); Tue, 8 Sep 2020 14:45:18 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:44342 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728899AbgIHSnp (ORCPT ); Tue, 8 Sep 2020 14:43:45 -0400 Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 088C3VsW004198; Tue, 8 Sep 2020 07:03:31 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599566611; bh=nsqPY6o4grvE2pz2lannxuY5WsjPIahg4+RoCYp/mc4=; h=Subject:From:To:CC:References:Date:In-Reply-To; b=ia2HCvqTdT2aSCL0/porgUy55z/i+UNq4fGm51IBwnjCi49OkizTxLE8QrQf5pLhG tNYc8imMXyJknGPW8h8Bjtcf/u01AeRfbs9KUtXdyT/+siXEYWnKXnxY9GGFMd0Cgj bZSQ1blN0Ra3RX6g1cY8xR/cDa84TcLT/G/RdfnA= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 088C3V75118701 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Sep 2020 07:03:31 -0500 Received: from DFLE110.ent.ti.com (10.64.6.31) by DFLE115.ent.ti.com (10.64.6.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3; Tue, 8 Sep 2020 07:03:31 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE110.ent.ti.com (10.64.6.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1979.3 via Frontend Transport; Tue, 8 Sep 2020 07:03:31 -0500 Received: from [192.168.2.6] (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id 088C3SxG114548; Tue, 8 Sep 2020 07:03:29 -0500 Subject: Re: [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset From: Peter Ujfalusi To: Camel Guo , , , , CC: , , , Camel Guo References: <20200908083521.14105-1-camel.guo@axis.com> <7bb93489-dbd5-d1a5-5df6-e62470bd2252@ti.com> X-Pep-Version: 2.0 Message-ID: Date: Tue, 8 Sep 2020 15:03:28 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <7bb93489-dbd5-d1a5-5df6-e62470bd2252@ti.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: quoted-printable 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 Hi, On 08/09/2020 14.59, Peter Ujfalusi wrote: >=20 >=20 > On 08/09/2020 11.35, Camel Guo wrote: >> From: Camel Guo >> >> When gpio_reset is not well defined in devicetree, the >> adcx140->gpio_reset is an error code instead of NULL. In this case, >> adcx140->gpio_reset should not be used by adcx140_reset. This commit >> sets it NULL to avoid accessing an invalid variable. >> >> Signed-off-by: Camel Guo >> --- >> sound/soc/codecs/tlv320adcx140.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv32= 0adcx140.c >> index 7ae6ec374be3..597dd1062943 100644 >> --- a/sound/soc/codecs/tlv320adcx140.c >> +++ b/sound/soc/codecs/tlv320adcx140.c >> @@ -984,8 +984,10 @@ static int adcx140_i2c_probe(struct i2c_client *i= 2c, >> =20 >> adcx140->gpio_reset =3D devm_gpiod_get_optional(adcx140->dev, >> "reset", GPIOD_OUT_LOW); >> - if (IS_ERR(adcx140->gpio_reset)) >> + if (IS_ERR(adcx140->gpio_reset) || adcx140->gpio_reset =3D=3D NULL) = { >> dev_info(&i2c->dev, "Reset GPIO not defined\n"); >> + adcx140->gpio_reset =3D NULL; >=20 > the correct fix is to: > dev_err(&i2c->dev, "Reset GPIO not defined\n"); no need to print, I think gpio core will do that. > return PTR_ERR(adcx140->gpio_reset); >=20 > If the reset GPIO is specified and you get error when requesting it as > optional, there is a reason for that. > For example deferred probing. >=20 >> + } >> =20 >> adcx140->supply_areg =3D devm_regulator_get_optional(adcx140->dev, >> "areg"); >> >=20 > - P=C3=A9ter >=20 > Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. > Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki >=20 - P=C3=A9ter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki