Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4144938pxk; Tue, 8 Sep 2020 11:48:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyITQ8y5tXmlBuMis3I4CnSVQAVC05JQ+KPihTrySJqXKefoF18+5HWw7zUzfe2JouyfF/6 X-Received: by 2002:a17:906:46d5:: with SMTP id k21mr26769786ejs.247.1599590882700; Tue, 08 Sep 2020 11:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599590882; cv=none; d=google.com; s=arc-20160816; b=aAuTfsFfY6Ny9722HqhCznfND8a2hUBETjcJGOFrzvvviRI21cycWnTLyQyRJCs0np s+aK014pyr0hONVcgfkHUbnRrY5zPGX5+r16k/KDBjdlkx9WKgjzaYFlL1OrsXb5sr1B pSIf7wgzp+ihUJXBA5NjvIhgROP1n9y61DjcBGSB9SNko7+Dgi3EezF2mjSk66dTFgQk eX8EBYg3KtinnpjqloyxGZDgta2/ncJxiJgesXjuQO8BM4W7GKMVvfTqbo7XgUW0/sgV XQcVhKRo3rg7Oj8b7z8N/ZJrrmb4kYqiQFKPblK72d4DSudmCfXjDgTNfpyzz8WoREXC xBlg== 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=GHYJnMapkkdtwKbXaCf924QThmz/JpeI2hL/70NG150=; b=bMOT+MqZ3VXiMX+OxFV8PPgYrMlquH2lJJaBhRAtSg03Hr3Fz/y3AdUdA/EB6rL1hk RAw8nJOEWzUjvIu10zcAU/jqZlNwqEXz6BzGCXvpLqFcXs4O+wIfC+PQ7DvJFhPyKlkv Jnmb1oBt2doHSTaDyLj8URX9bX46RngnWgdx9vR/vEkO8Na4MgZYN576ovTXFPPu6c5B lAOLS2iIQkvcAt1L//fJ56Rjf0kZRe/Ltn6HRz5BweEC3mbBWIX1/33C6r3ig63H9Kkx jwkUhpQs1qUn7CWi49KTTKoQGqPSCW9zrNlznt2XIA2FEsVIXjlfgs8uwaDZ9FHoeIvK sDsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=xlLdRIqa; 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 ga23si12210073ejb.691.2020.09.08.11.47.39; Tue, 08 Sep 2020 11:48:02 -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=xlLdRIqa; 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 S1731409AbgIHSp0 (ORCPT + 99 others); Tue, 8 Sep 2020 14:45:26 -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 S1731361AbgIHSnn (ORCPT ); Tue, 8 Sep 2020 14:43:43 -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 088Bxpk5003236; Tue, 8 Sep 2020 06:59:51 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1599566391; bh=GHYJnMapkkdtwKbXaCf924QThmz/JpeI2hL/70NG150=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=xlLdRIqazwVVbzo7UeRzA2/7sMEVFq7YrBOd3qDrFyS4bBFAcKmwBXV2FraRpCHE3 W8efGNVqWeo3YfMaB6LbtIvI/DNgAkYD8fuXwlUwLsRC/jyyDYbCSPxcKlt6PCzZzF yVvYn/xstctyldCJuCRHc9cqh/M+TvJH3haidCfY= 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 088BxpDV112728 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 8 Sep 2020 06:59:51 -0500 Received: from DFLE104.ent.ti.com (10.64.6.25) 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 06:59:51 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE104.ent.ti.com (10.64.6.25) 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 06:59:51 -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 088BxmR5107470; Tue, 8 Sep 2020 06:59:49 -0500 Subject: Re: [PATCH 1/2] ASoC: tlv320adcx140: Avoid accessing invalid gpio_reset To: Camel Guo , , , , CC: , , , Camel Guo References: <20200908083521.14105-1-camel.guo@axis.com> From: Peter Ujfalusi X-Pep-Version: 2.0 Message-ID: <7bb93489-dbd5-d1a5-5df6-e62470bd2252@ti.com> Date: Tue, 8 Sep 2020 14:59:48 +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: <20200908083521.14105-1-camel.guo@axis.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 On 08/09/2020 11.35, Camel Guo wrote: > From: Camel Guo >=20 > 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. >=20 > Signed-off-by: Camel Guo > --- > sound/soc/codecs/tlv320adcx140.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > diff --git a/sound/soc/codecs/tlv320adcx140.c b/sound/soc/codecs/tlv320= adcx140.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 *i2= c, > =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; the correct fix is to: dev_err(&i2c->dev, "Reset GPIO not defined\n"); return PTR_ERR(adcx140->gpio_reset); 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 > adcx140->supply_areg =3D devm_regulator_get_optional(adcx140->dev, > "areg"); >=20 - P=C3=A9ter Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki