Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758325AbcJQWO5 (ORCPT ); Mon, 17 Oct 2016 18:14:57 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:56284 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754520AbcJQWOt (ORCPT ); Mon, 17 Oct 2016 18:14:49 -0400 From: Arnd Bergmann Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Arnd Bergmann , Ico Doornekamp , Jonathan Cameron , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , Greg Kroah-Hartman , Ioana Ciornei , Luis de Bethencourt , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org Subject: [PATCH 14/28] iio: accel: sca3000_core: avoid potentially uninitialized variable Date: Tue, 18 Oct 2016 00:13:35 +0200 Message-Id: <20161017221355.1861551-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161017220342.1627073-1-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> X-Provags-ID: V03:K0:CFNpGmzDqZgvjTvOz4WmZ1TfH5wYAscbqWDCHM+O4trTjYmB2Rs p1zMg9/+28FLnpKfZzKOOUbZp0GsWPDADI+PYBph/WkO3omqDf2oiP3u9QiBgCe+v8x0qzn H5MKdW+IZ7vwnPB30Y6Z5qEF+jzmnInYlWWNSCqr4vgTpfQndS5IKJzl/1b9WFdDFVsoO78 8RJhdyg3/6k1+UXtbmK2g== X-UI-Out-Filterresults: notjunk:1;V01:K0:P60xLuNvSvo=:5YUBW+HfQVfgbbilz+3GIV InoZBWHR0dvnE5OBe9rTCrHT24qz7pthzkLZkl1pRIVHaA6mD6k+GU8ngBU4Aof5hdF9vR4J6 Sm1S1eXkWxZVWLs4etzyyX0xjKZoDW7Ll5T+ztmRLpoeu0ijXOcQNb8Uvupt35s5Fj9On1y3z Iru+/Ou5X/57tMmF5yhW2cPex00OL7+HMNjjuMKT1Tk+1l1j649fkQoTiGP0KCoijFgdhpogr 1Is6VYWkJSrfvS8aqUrlaVO+CMgmXWxidNSmVzpjAI+whHSvuRg+dlqWVwlkJxXYeroarV4kU YyghORe0SgXgXJy8Im5S5q81yJeIQ7pzlQeyH5HI+chkIorYdLQiU4CaqB0yVChvnsOBzjU0i iSLaFW3zSrmXqq7Kpiu6Piiov6kmIR8TLDhnKcpswjrW92Kjjwyahefnw+dKRkV0AcsNW91v6 oZML/doLX9X4ZgeY8Nwj0qnX+LN4VE6pJQGH2N3D01PsrZXh8OkNlb4zu/UxFqKGgcltlivBm sLkLuEwWHn0WnkPNVwNZN8kASi4G1SahbxIlvNUvapt48zrURahHrQYBwJNRQr5hfRXHM8l6y DFf83XvXQfLr306nagIHFzHlL1OtslZm3CtIu/9PpDGgpl+SzySP0VJAaihDXhqIKkvw0UVHg 1N0JBI8ytQzj0C6npeuOt8gvUzFW5q3ZxTHIN8W+gOX/nfwlS21BH+T7sa57LcUD+TjE= To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1568 Lines: 41 The newly added __sca3000_get_base_freq function handles all valid modes of the SCA3000_REG_ADDR_MODE register, but gcc notices that any other value (i.e. 0x00) causes the base_freq variable to not get initialized: drivers/staging/iio/accel/sca3000_core.c: In function 'sca3000_write_raw': drivers/staging/iio/accel/sca3000_core.c:527:23: error: 'base_freq' may be used uninitialized in this function [-Werror=maybe-uninitialized] This adds explicit error handling for unexpected register values, to ensure this cannot happen. Fixes: e0f3fc9b47e6 ("iio: accel: sca3000_core: implemented IIO_CHAN_INFO_SAMP_FREQ") Signed-off-by: Arnd Bergmann Cc: Ico Doornekamp Cc: Jonathan Cameron --- I submitted this on Sept 22, and Jonathan said he applied it to his 'togreg' tree, but it hasn't appeared in linux-next yet, presumably since this was not considered material for v4.9. If we enable the warning again by default, we may want to have the fix merged for v4.9 after all. drivers/staging/iio/accel/sca3000_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/iio/accel/sca3000_core.c b/drivers/staging/iio/accel/sca3000_core.c index d626125..564b36d 100644 --- a/drivers/staging/iio/accel/sca3000_core.c +++ b/drivers/staging/iio/accel/sca3000_core.c @@ -468,6 +468,8 @@ static inline int __sca3000_get_base_freq(struct sca3000_state *st, case SCA3000_MEAS_MODE_OP_2: *base_freq = info->option_mode_2_freq; break; + default: + ret = -EINVAL; } error_ret: return ret; -- 2.9.0