From patchwork Wed May 11 12:49:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9069211 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8F79F9F30C for ; Wed, 11 May 2016 12:51:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 82650201BB for ; Wed, 11 May 2016 12:50:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 989EF20172 for ; Wed, 11 May 2016 12:50:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751836AbcEKMu5 (ORCPT ); Wed, 11 May 2016 08:50:57 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:55471 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbcEKMu5 (ORCPT ); Wed, 11 May 2016 08:50:57 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0Lno43-1bXtjk3EQp-00hs9k; Wed, 11 May 2016 14:50:15 +0200 From: Arnd Bergmann To: Kishon Vijay Abraham I Cc: Arnd Bergmann , Kukjin Kim , Krzysztof Kozlowski , Sylwester Nawrocki , Marek Szyprowski , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH] phy: exynos-mipi-video: avoid uninitialized variable use Date: Wed, 11 May 2016 14:49:53 +0200 Message-Id: <1462971012-562097-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:cX9b5cLBD0sFJFaAaz7cmgoUDAA99K6cBQwtExGwpxiWkglcRxN FZDsSOqc3Bsl1V2w3xo00QXADVhtVPi/oj28LE4wB2pBJ2rYpZiJq8vRGyati8fMRha7Tlr yI4UsEjp0vVcWw5X1ped7lvKMti5eHR8j3WyWb/Nlq0ShSLjnkyLDtWavTdN3TnzxYROoPV jrflTY7iuxGitWVGArDvA== X-UI-Out-Filterresults: notjunk:1; V01:K0:iyBE0SwheI4=:PvrqXwTYLzQQbQkOe2cAyH oEdhRTDI173xjTVnRSIrp/cczHiheRi7a3kRe88/3dlkVSoEeyD/tN1rPGZZf2PpxYG/f5wzU smNiejnb2SSRhyXd8Z/Ih3aFFrjqyyzJ2fM4LBEZm2quanMHWmjHZnMDen831Qgth8TF+Y8yv IihAex7qkXyO7NlsLJGfq3cX9Kc/ptRw74mCMku6XXVpbuVHb5e9y4gKoD8rvDypIt1jbDexZ Z8jz9Ljkb3QWo1+TRxXAHNZKBS2d6CqyHK7Tc3Fm2RKocoKvpkduNRhgR50qZhs4NxO3AIMO5 2+dReTDysp2QUyqflL2/rmPelNh/j/lp/6FgxJIlJQtvMoK3e7VA7kIiMqrLjc1f49vB3450h 7V3W1tK87ecdWv7186c/ovTOr7Y/mKWMKgyy2hnf3lvsgktkfvMzcxNTGa9rKjgiuUZVE5Bgj ifDgdB0chB4vhUUH97WZ4U/r5lFjZv/R2+DUmyYYtmpxu4og2tyveb1/936aDFHvzViPeqrFg bZkf/imd3uz6T1mHw52Yg8WE8+Pc5Hh+tzJh1fMll6PDLhXOTCWd66WbAx0lY0/CXo48FPTUP AG8EmVT3phFiGWRLF1PBIqltWrAwgI+Bd8rYW/qzdvm+IpxNwITrNBdVcWhC6RfByIsw2EUqW qJcBw2dvmeu1MFxuACSLRvBcrHIkXQ+xJXsj+SvA2PuNgCLEG1BKGV7h3Hgf1mutRO2k= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A rework of the exynos-mipi-video driver caused a warning about the new __set_phy_state function potentially accessing a variable before its initialization: drivers/phy/phy-exynos-mipi-video.c: In function '__set_phy_state': drivers/phy/phy-exynos-mipi-video.c:238:13: error: 'val' may be used uninitialized in this function [-Werror=maybe-uninitialized] return val & data->resetn_val; ~~~~^~~~~~~~~~~~~~~~~~ drivers/phy/phy-exynos-mipi-video.c:235:6: note: 'val' was declared here u32 val; The failure scenario here is the offset passed into a the stub regmap_read() function that does not modify its output, however regmap_read() can also fail for other reasons, so adding error handling (in this case, returning zero from is_running) seems the best solution. Note that this warning showed up with the ARM s5pv210_defconfig, indicating that we most likely want to either enable CONFIG_REGMAP in that defconfig as well, or disable the phy-exynos-mipi-video driver. Signed-off-by: Arnd Bergmann Fixes: 97a3042f7616 ("phy: exynos-mipi-video: Rewrite handling of phy registers") Reviewed-by: Krzysztof Kozlowski --- drivers/phy/phy-exynos-mipi-video.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/phy/phy-exynos-mipi-video.c b/drivers/phy/phy-exynos-mipi-video.c index cc093ebfda94..8b851f718123 100644 --- a/drivers/phy/phy-exynos-mipi-video.c +++ b/drivers/phy/phy-exynos-mipi-video.c @@ -233,8 +233,12 @@ static inline int __is_running(const struct exynos_mipi_phy_desc *data, struct exynos_mipi_video_phy *state) { u32 val; + int ret; + + ret = regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); + if (ret) + return 0; - regmap_read(state->regmaps[data->resetn_map], data->resetn_reg, &val); return val & data->resetn_val; }