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: 101118 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp1437230lbb; Mon, 25 Jan 2016 07:52:51 -0800 (PST) X-Received: by 10.66.101.36 with SMTP id fd4mr27201162pab.76.1453737171683; Mon, 25 Jan 2016 07:52:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o5si34425947pfa.151.2016.01.25.07.52.51; Mon, 25 Jan 2016 07:52:51 -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 S933112AbcAYPwq (ORCPT + 30 others); Mon, 25 Jan 2016 10:52:46 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:52688 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932835AbcAYPwZ (ORCPT ); Mon, 25 Jan 2016 10:52:25 -0500 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 Cc: linux-arm-kernel@lists.infradead.org, Arnd Bergmann , Jonathan Cameron , Hartmut Knaack , Peter Meerwald , Greg Kroah-Hartman , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org 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= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.0 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,