From patchwork Mon Dec 10 14:25:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Kepplinger X-Patchwork-Id: 10721339 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E3D82112E for ; Mon, 10 Dec 2018 14:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D4E982A958 for ; Mon, 10 Dec 2018 14:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C8C142A95F; Mon, 10 Dec 2018 14:25:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2011B2A958 for ; Mon, 10 Dec 2018 14:25:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727580AbeLJOZt (ORCPT ); Mon, 10 Dec 2018 09:25:49 -0500 Received: from mout01.posteo.de ([185.67.36.65]:60505 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727561AbeLJOZt (ORCPT ); Mon, 10 Dec 2018 09:25:49 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 559B4160061 for ; Mon, 10 Dec 2018 15:25:46 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1544451946; bh=ZbdLLynQFF4YAxEpdc4KubVeNp+GKs+sQWGzNGrKTr0=; h=From:To:Cc:Subject:Date:From; b=UnJ2bqteHT6GAKQyad+nhF2ClOPeA4nhJ/NiuLdiCVQrA83/YkEGuRhnLZ84OhKE6 yVS66ylzh21yQiHbBKsSJjEcXMdnclLhqQQoq8Oht5WluOhvTB6Ukaywq4VUXKVvAd TgdyLWj/NorToVQqOOz1loeC8QaYHrZ9KFpFiLjy7t0l78stbs279UxHrj8dMoWItQ qsl0KtRHAJHTFIcNkLV+v33cRTZxGMi3s5hpg2qt2duh4S6nLAXnOxxTzYmWM+HLOh HmQ5sZMg+faBcBSUobWRLPEV7aPFTPRInRNglYtTmeZxqQ6RP44/fbFi3wghxuVrRY fRzviDmUMZbrw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 43D52w6vsmz6tmK; Mon, 10 Dec 2018 15:25:44 +0100 (CET) From: Martin Kepplinger To: jic23@kernel.org, knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Kepplinger Subject: [PATCH] iio: accel: mma9551_core: prevent using uninitialized variable Date: Mon, 10 Dec 2018 15:25:32 +0100 Message-Id: <20181210142532.15315-1-martink@posteo.de> X-Mailer: git-send-email 2.11.0 Sender: linux-iio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-iio@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP mma9551_gpio_config()'s switch statement sets the uninitialized pol_mask variable but doesn't have default settings. Said function can therefore be called in a way to use the uninitialized variable (at least in case enum mma9551_gpio_pin is extended with unhandled values). While things should be fine now, this initializes pol_mask just to prevent failure. Signed-off-by: Martin Kepplinger --- drivers/iio/accel/mma9551_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c index c34c5ce8123b..2fc79b14888b 100644 --- a/drivers/iio/accel/mma9551_core.c +++ b/drivers/iio/accel/mma9551_core.c @@ -539,7 +539,8 @@ EXPORT_SYMBOL(mma9551_update_config_bits); int mma9551_gpio_config(struct i2c_client *client, enum mma9551_gpio_pin pin, u8 app_id, u8 bitnum, int polarity) { - u8 reg, pol_mask, pol_val; + u8 reg, pol_val; + u8 pol_mask = 0; int ret; if (pin > mma9551_gpio_max) {