From patchwork Mon Jan 25 15:50:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8110281 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D1FB4BEEE5 for ; Mon, 25 Jan 2016 15:53:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0CF4F2034A for ; Mon, 25 Jan 2016 15:53:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 318AE201D3 for ; Mon, 25 Jan 2016 15:53:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aNjRS-0000jh-07; Mon, 25 Jan 2016 15:52:34 +0000 Received: from mout.kundenserver.de ([212.227.126.187]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aNjRA-0000N6-QB for linux-arm-kernel@lists.infradead.org; Mon, 25 Jan 2016 15:52:20 +0000 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue002) with ESMTPA (Nemesis) id 0M7hEO-1aAcOd2xzk-00vQlv; Mon, 25 Jan 2016 16:51:43 +0100 From: Arnd Bergmann To: Lars-Peter Clausen , Michael Hennerich Subject: [PATCH] staging: iio: ad5933: avoid uninitialized variable in error case Date: Mon, 25 Jan 2016 16:50:46 +0100 Message-Id: <1453737099-1959671-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:knaWImNiDvn8P5lidlC0ygy4IwyM44Oafj/zBbdE/TcyF57hu5R J5tDJaHg4633u1Hz5U/1qh3s3bFLd9I9plMnr5jlfDTY+Hp5twVYTdFyXYJWlAPxg6ZuI35 T0WnCP6/5ZUvBE2x/m0E+nIeSZUKTTDrZ12fSnLdjGqTMaIcJo8Dg28U44lzyOIXTlw9a2R A5kYVRJHZQeXRyy/ydzzg== X-UI-Out-Filterresults: notjunk:1; V01:K0:v0wQ4vES/Xs=:ZhiT1yGD4BNsYtCVuGG308 kSxrYatCumcXwAwAtbuevybAlo1NzsUsGV2m+mgu5g9hfSqbN/WZfCsNhddH5wKsFtT9m/5sZ eLT0TuqYYA3pQFb99TZOcDrCtYnGaxjcZiKflhG3hGiiEwuSzHA1fQB6GV8+3R5Pc8hZOyomm 2rmGUwAhFRTkOAyuChGI1hyjSYmhMD08XDCnZVuz6VTsR2A+KsHYTOuLkwGv0XFhKZWePqTsJ Mj28/+bD9u7fXciG0pgGYI95lnabsEWInqwNaLVNZ7b4hHNFw3PJwZFWD05YuKDz01Q7idL21 CGTUaPeKzx4b+hz/6KH9LBXnDbPMHzM4mAqIt/pdjdNhxkk5p+BM/6DUBUR9PYJVZnyZg2hOg gXi0a2es16nYgnxltU2pQILD2w/vyjP8tMdpugvf/F5FtGxwTph29MO/qjUguXvI2m+l4eO29 /FFvNUj2S60fiZKNiSfT1cUy7G27qRJybF9zo4Az0dB/IVa8GWnxZPeMziw/Bpo6zK+ZGaA9h /YRl3p8v1Nogl7/87kTysbhS0Jc4ovcGzxGEvwq3l2+CU1trid9hdILnkpQp91f0Uj5WHHqeI 9FkkiARdMdSmtFfY3F+Jv30UygjgjSUg31o6/Zavl19GZO3f3mGkNSH0FNQy02cBdCAIr4efx WrbyhXxQRewCKkf49K5zW3F3f4bFaAl+uqImVwGp+C7hrtBmHhr9oC9u/kbrqUAzupC4= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160125_075217_460522_DB986CA1 X-CRM114-Status: GOOD ( 13.08 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devel@driverdev.osuosl.org, Arnd Bergmann , linux-iio@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Peter Meerwald , Hartmut Knaack , Jonathan Cameron MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 The ad5933_i2c_read function returns an error code to indicate whether it could read data or not. However ad5933_work() ignores this return code and just accesses the data unconditionally, which gets detected by gcc as a possible bug: drivers/staging/iio/impedance-analyzer/ad5933.c: In function 'ad5933_work': drivers/staging/iio/impedance-analyzer/ad5933.c:649:16: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized] This adds minimal error handling so we only evaluate the data if it was correctly read. Signed-off-by: Arnd Bergmann --- drivers/staging/iio/impedance-analyzer/ad5933.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/staging/iio/impedance-analyzer/ad5933.c b/drivers/staging/iio/impedance-analyzer/ad5933.c index 10c43dda0f5a..304bb464e478 100644 --- a/drivers/staging/iio/impedance-analyzer/ad5933.c +++ b/drivers/staging/iio/impedance-analyzer/ad5933.c @@ -647,6 +647,7 @@ static void ad5933_work(struct work_struct *work) __be16 buf[2]; int val[2]; unsigned char status; + int ret; mutex_lock(&indio_dev->mlock); if (st->state == AD5933_CTRL_INIT_START_FREQ) { @@ -658,9 +659,9 @@ static void ad5933_work(struct work_struct *work) return; } - ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); + ret = ad5933_i2c_read(st->client, AD5933_REG_STATUS, 1, &status); - if (status & AD5933_STAT_DATA_VALID) { + if (!ret && (status & AD5933_STAT_DATA_VALID)) { int scan_count = bitmap_weight(indio_dev->active_scan_mask, indio_dev->masklength); ad5933_i2c_read(st->client,