From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752511AbcEKMu6 (ORCPT ); Wed, 11 May 2016 08:50:58 -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 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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- 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; } -- 2.7.0