From patchwork Thu Nov 10 16:44:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9421561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id F087360512 for ; Thu, 10 Nov 2016 16:50:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 010B22976F for ; Thu, 10 Nov 2016 16:50:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E668829776; Thu, 10 Nov 2016 16:50:06 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 DA0312976F for ; Thu, 10 Nov 2016 16:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935255AbcKJQra (ORCPT ); Thu, 10 Nov 2016 11:47:30 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:50852 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935157AbcKJQr0 (ORCPT ); Thu, 10 Nov 2016 11:47:26 -0500 Received: from wuerfel.lan ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MdifM-1cS4CN2ia4-00PMDb; Thu, 10 Nov 2016 17:45:39 +0100 From: Arnd Bergmann To: Linus Torvalds Cc: Andrew Morton , Arnd Bergmann , Anna Schumaker , "David S. Miller" , Herbert Xu , Ilya Dryomov , Javier Martinez Canillas , Jiri Kosina , Jonathan Cameron , Ley Foon Tan , "Luis R . Rodriguez" , Martin Schwidefsky , Mauro Carvalho Chehab , Michal Marek , Russell King , Sean Young , Sebastian Ott , Trond Myklebust , x86@kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, nios2-dev@lists.rocketboards.org, linux-s390@vger.kernel.org, linux-crypto@vger.kernel.org, linux-media@vger.kernel.org, linux-nfs@vger.kernel.org Subject: [PATCH v2 03/11] x86: apm: avoid uninitialized data Date: Thu, 10 Nov 2016 17:44:46 +0100 Message-Id: <20161110164454.293477-4-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161110164454.293477-1-arnd@arndb.de> References: <20161110164454.293477-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:FA+4+ZuQg6TKlMDkxqXV9t+fqJGK2+oy/5d6qv5X5bZI0OeI2ms HGGT4pvARZnvsUJew22xH3sP5Wsy71gnEGH+WUgeFfpLdEHzTgxWWGmc7Jqr0cHZoKZDGhC tAb9s1wRugICk5O4srwGHNEfshXgBz5MKsKpID5whJbROvE+pAIVDJTzMd71xKXf2LX7sOo 3IQu6BEZCIg9CLD3wAgnQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:SJJy76HFdQg=:0L+I6UOk3+/UjBVEe8z+yL kzL7Dwt+Z5GsF2aZu3yb0O5f60yeiwiBd7JtuAXjhU77oc9oqRyq3henp05XQnjuNlvUwB115 XZA+Zt2/qjv706zLfJr7Jsj1Katk2Ki17KA0ZiTOFiM7gZ99J/1f3jGBru8viC5sPAYMmE2NZ OrOELCvAD9IsWNBDsxzYT7xfcAW933FyPZJnG718/EEeVyklTeE0wu67ibdQ5TWQ7KRfYvgEj 6Kxk+bbnWgyvu1yLGGh0xBKgZqYRqq6n3e3ynKdHgvHaXl7s/Py0MyU3rfR8qJvCxlA3bRV3q 1kN+bLZ85pLrCoTlONv1ZRrDiN4sFUpabej9yyYHBXGeRzYYfZo6YnPGqErvsos5V9M7fieBd 8/dBw0gGnzS8zSVecmNQlNKZ0aYIzifXuIheUudG5rGGd9/tPuOADke2ygC4mxTH1MT0D2D16 wyQOYnYqQ0Rt8dJx/UftFmiFfJOO7nTXNW7ujd0121hY7/8XYSIDqZDbXCNilDRSUXvqvZOtX 6WKHHs1SxDuJBnj87t0hCnKhiEWgvhMfhQphr/p4YWEFLiam7+KQ7BouWHThqyeydSZNkEl1t RJMHVUdzZfRqAKdjOZhrlC2WtWoUGMmMqbHfAB6cd0Jiu05/5bVCMdTZNgoGltI5ZIkDvs7Oz /JKploftbtd4A1DqvOdDxrYdCjOouFlUt2AOfNnq93VpSB+drU4StBBSNJArONgCwHDvQ6H9d g65dzzKh21abdkFu Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP apm_bios_call() can fail, and return a status in its argument structure. If that status however is zero during a call from apm_get_power_status(), we end up using data that may have never been set, as reported by "gcc -Wmaybe-uninitialized": arch/x86/kernel/apm_32.c: In function ‘apm’: arch/x86/kernel/apm_32.c:1729:17: error: ‘bx’ may be used uninitialized in this function [-Werror=maybe-uninitialized] arch/x86/kernel/apm_32.c:1835:5: error: ‘cx’ may be used uninitialized in this function [-Werror=maybe-uninitialized] arch/x86/kernel/apm_32.c:1730:17: note: ‘cx’ was declared here arch/x86/kernel/apm_32.c:1842:27: error: ‘dx’ may be used uninitialized in this function [-Werror=maybe-uninitialized] arch/x86/kernel/apm_32.c:1731:17: note: ‘dx’ was declared here This changes the function to return "APM_NO_ERROR" here, which makes the code more robust to broken BIOS versions, and avoids the warning. Signed-off-by: Arnd Bergmann Reviewed-by: Jiri Kosina Reviewed-by: Luis R. Rodriguez --- arch/x86/kernel/apm_32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index c7364bd..51287cd 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c @@ -1042,8 +1042,11 @@ static int apm_get_power_status(u_short *status, u_short *bat, u_short *life) if (apm_info.get_power_status_broken) return APM_32_UNSUPPORTED; - if (apm_bios_call(&call)) + if (apm_bios_call(&call)) { + if (!call.err) + return APM_NO_ERROR; return call.err; + } *status = call.ebx; *bat = call.ecx; if (apm_info.get_power_status_swabinminutes) {