Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp505958ima; Wed, 6 Feb 2019 03:55:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbDY8p88xW6Qz4NlRaeXOZy8NVt49RSI1cFHi5sYVhuiwp+tLU2QH/beVxk74TqkDA8E3mA X-Received: by 2002:a17:902:209:: with SMTP id 9mr10425927plc.288.1549454142404; Wed, 06 Feb 2019 03:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549454142; cv=none; d=google.com; s=arc-20160816; b=n6I6TNxBnzsmGb4UqSssI4fI9/c95COqeHc3uOKUuOTspSdV/ZL+LwFIOabY9e7OnO QRqruJUJmX9TvdUj+FJToEnVizrIGHOolkg076HhrucsUPWqVUsKaVDQiOR4bGCjh/xm UGgCPd4Alp3f6iVri5t7Sl0ZpxyigiL0iHTWByd8OS+4vZDl6RQb2vgBaZLwyFoJ6bux fv8XVDrQ+G6A7xb6SuEzzT28KKJxn54L4OK/jiBVLzK7BpcsFg1qjSqnZorG2e/HjwQq hnaxrjSeq/MPNVEZ60LBZorn4oSIqFiGQlLAGWmY033whYOSb9NPTSokK77XWKNqMBlR +slA== 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=s5K0Ey4SGK5w8YpCgMjlhFy0N+qYzohFi2PAXBpSKLs=; b=RY2mG9BCQF94JbqvGMhTfP2KQB2IGMXnayijwkG4dkmOZsRRZ+pKpmy7Xs4PpIA/a2 TvX+umqUcS8ALKwqDpbNyPiQNhtMQdjIZJa1W1HFkK2pb/7/TXEkpogXUp/vqcB7DXGl Xo76CZrdfBQ+eSE9ymAvw+6GK+I47jpC3VNTi0AJwDgnLQchPkThHpOfTFyXIkUReoME o1KTIznygQXzO6hhfEL8fq0RcJhSsnwuYSPtC3fRUNRnmGNt8kbPFwcx0iyWUGJVuDPt IyGc16CMgsdf8b29lvpdZCvyeEqOy/jE5n66scWZsP4n6Sw8qzdQARPPriD4FiG7wAI7 M5Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=MZEQvWlM; 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 p22si5666256plr.186.2019.02.06.03.55.26; Wed, 06 Feb 2019 03:55:42 -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=MZEQvWlM; 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 S1730009AbfBFLhZ (ORCPT + 99 others); Wed, 6 Feb 2019 06:37:25 -0500 Received: from lelv0142.ext.ti.com ([198.47.23.249]:44382 "EHLO lelv0142.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727797AbfBFLhZ (ORCPT ); Wed, 6 Feb 2019 06:37:25 -0500 Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id x16BbGPf028665; Wed, 6 Feb 2019 05:37:16 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1549453036; bh=s5K0Ey4SGK5w8YpCgMjlhFy0N+qYzohFi2PAXBpSKLs=; h=Subject:To:CC:References:From:Date:In-Reply-To; b=MZEQvWlM/FJaDwHoTA7cl/Sy3GuQQ2ACMIvpB7fQXp73FZ53C149KU5qJOwudOEGH ATocw6WY3AdE5+0yrvuC5QR5L7IxSSDHee5ISKFEYswSD+iX5Vaa6vWEXONWTmdEGB i1nKhu9EOpdWEN3uFlhtVdahq0/aHXCC8gyeGjEg= Received: from DLEE113.ent.ti.com (dlee113.ent.ti.com [157.170.170.24]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x16BbGiZ002507 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 6 Feb 2019 05:37:16 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 6 Feb 2019 05:37:16 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1591.10 via Frontend Transport; Wed, 6 Feb 2019 05:37:16 -0600 Received: from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id x16BbD8W009284; Wed, 6 Feb 2019 05:37:14 -0600 Subject: Re: [PATCH] phy: Variable "val" in function miphy_osc_is_ready() could be uninitialized To: Yizhuo CC: , , Patrice Chotard , , References: <20190206033036.22729-1-yzhai003@ucr.edu> From: Kishon Vijay Abraham I Message-ID: Date: Wed, 6 Feb 2019 17:06:43 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: <20190206033036.22729-1-yzhai003@ucr.edu> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit 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 Yizhuo, On 06/02/19 9:00 AM, Yizhuo wrote: > In function miphy_osc_is_ready(), local variable "val" > could be uninitalized. if function regmap_read() returns > -EINVAL. However, this value is used in if statement. > This is potentially unsafe. > > Signed-off-by: Yizhuo Can you send all your fixes in a series? Thanks Kishon > --- > drivers/phy/st/phy-miphy28lp.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/st/phy-miphy28lp.c b/drivers/phy/st/phy-miphy28lp.c > index 213e2e15339c..40c7c0a611a0 100644 > --- a/drivers/phy/st/phy-miphy28lp.c > +++ b/drivers/phy/st/phy-miphy28lp.c > @@ -835,7 +835,8 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy) > { > struct miphy28lp_dev *miphy_dev = miphy_phy->phydev; > unsigned long finish = jiffies + 5 * HZ; > - u32 val; > + u32 val = 0; > + int ret; > > if (!miphy_phy->osc_rdy) > return 0; > @@ -844,8 +845,10 @@ static int miphy_osc_is_ready(struct miphy28lp_phy *miphy_phy) > return -EINVAL; > > do { > - regmap_read(miphy_dev->regmap, > + ret = regmap_read(miphy_dev->regmap, > miphy_phy->syscfg_reg[SYSCFG_STATUS], &val); > + if (ret) > + return ret; > > if ((val & MIPHY_OSC_RDY) != MIPHY_OSC_RDY) > cpu_relax(); >