Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3706047imj; Tue, 12 Feb 2019 03:20:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IbVzsib0w6i30wJfTYmWLzsycccR48h/Sw2VZCsrQ9930M4qhANesHchif59vckz3Tkx062 X-Received: by 2002:a17:902:722:: with SMTP id 31mr3478168pli.271.1549970434398; Tue, 12 Feb 2019 03:20:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549970434; cv=none; d=google.com; s=arc-20160816; b=BOIVKqRyjDHG/keBksoqliL3a2zUyXriGo3dFjFfQ6exTOUdWolmkRn3m5MJAPKE0f k1kxJxxJHu6IfvTuqJsdGR0cPqvGDC9L0sXOuewV5EQQ2dG34q6TM0tXlmOrCi50u+d7 GYUxXhb1KRKPvKuWNe/yHAMFqvY5RjTK/qakZYPSb2zosIKzE8yFvdpooVRCpuj+FQab RHUT2ULYy7jCKkFWwYEoDyJSIcu7gMt8PW+esqlw6E/fFqFnnhfCTK5Jk6Adb3BBvn7+ BAm+3bf5xoUL6/kSX+k2khGkEH2mEuSIJ4pcl7j+j+1vk4g6npYMhsQtbTAlD7dir5l0 7vJg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=o4EQsJvPg8NEEneWxOhTVgIeyP2GeexW1dR+Vp8SUFY=; b=P1PqmWLe3v+4nOUZHn6P/flirLo9Fp0BVPhfU9fiTXtZoM+jUmjbpJQw7Jm3GvMqn8 oMf1RuVzK3Ths2o65msHpz2fp572vSvDKFN7sTb80MpLxYuw7lMvZ5UIGzfeHnyvArLg mxoZCrFW452O5c9EpsAejTmmtMWAKRqsWs3QCRsJgKWyYdkhEwwaTvOP4tOSDw1UGKTe 4Y+xH7I0Y41lq1qZFlJCte1phNuNcMP0SI3qDt7L41jh2VgBUe9xayeE+bCVwPL30y6u HQKq0R3UqsJm5kJSF34fccQR52ZC5ugTqSkaA16dq1FyMteAmgiKcz6RSuOdDqtE9T1y B6Ag== ARC-Authentication-Results: i=1; mx.google.com; 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 r7si13663669ple.281.2019.02.12.03.20.18; Tue, 12 Feb 2019 03:20:34 -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; 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 S1728136AbfBLKtz (ORCPT + 99 others); Tue, 12 Feb 2019 05:49:55 -0500 Received: from gloria.sntech.de ([185.11.138.130]:35322 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726049AbfBLKtz (ORCPT ); Tue, 12 Feb 2019 05:49:55 -0500 Received: from ip5f5a6320.dynamic.kabel-deutschland.de ([95.90.99.32] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gtVdP-00014V-Tf; Tue, 12 Feb 2019 11:49:51 +0100 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Yizhuo Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, Kishon Vijay Abraham I , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org Subject: Re: [PATCH] phy: rockchip-typec: Variable "val" of function rockchip_usb3_phy_power_on() could be uninitialized Date: Tue, 12 Feb 2019 11:49:51 +0100 Message-ID: <3410531.oxWKaip9ZE@diego> In-Reply-To: <20190206021810.21596-1-yzhai003@ucr.edu> References: <20190206021810.21596-1-yzhai003@ucr.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, 6. Februar 2019, 03:18:10 CET schrieb Yizhuo: > In function rockchip_usb3_phy_power_on(), local variable > "val" could be uninitialized if function regmap_read() > returns -EINVAL. However, this value is directly used in > later context. This is potentially unsafe. While highly unlikely case (GRF-registers are mmio-based), it's still nicer to go the clean way, so Reviewed-by: Heiko Stuebner > Signed-off-by: Yizhuo > --- > drivers/phy/rockchip/phy-rockchip-typec.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/phy/rockchip/phy-rockchip-typec.c > b/drivers/phy/rockchip/phy-rockchip-typec.c index > a958c9bced01..b1e24418cb2d 100644 > --- a/drivers/phy/rockchip/phy-rockchip-typec.c > +++ b/drivers/phy/rockchip/phy-rockchip-typec.c > @@ -716,7 +716,10 @@ static int rockchip_usb3_phy_power_on(struct phy *phy) > > /* wait TCPHY for pipe ready */ > for (timeout = 0; timeout < 100; timeout++) { > - regmap_read(tcphy->grf_regs, reg->offset, &val); > + ret = regmap_read(tcphy->grf_regs, reg->offset, &val); > + if (ret) > + goto unlock_ret; > + > if (!(val & BIT(reg->enable_bit))) { > tcphy->mode |= new_mode & (MODE_DFP_USB | MODE_UFP_USB); > goto unlock_ret;