From patchwork Thu May 18 20:21:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 100132 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp8151qge; Thu, 18 May 2017 13:23:08 -0700 (PDT) X-Received: by 10.98.194.66 with SMTP id l63mr6476416pfg.234.1495138988706; Thu, 18 May 2017 13:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495138988; cv=none; d=google.com; s=arc-20160816; b=PYfF0KbNkkAXOJCAmkoNpUhNSNC/G4cGqAT6I3qlZCtO9mDnxeXs3WoQDtJPmy1MwW ABK6ALoOXAmmrjwKxyi6DuBv0uHrfy7brCglOsGeYlng9237KXqnFtPfTSdFH2VM4kQz 19CmuEYn3bt5lguettUPph1SzSpUwIGDbGcDg7nVEFMPw4IRVBGUA8RDbQDJCEf3t3WY 9ZeQbQtCPwtWWZMoNgJeTa8lWuUTecvLRHnVKyxFEghvpqG0c64dPKtqwXq7TKg+frQn jfc94ZbAK68yH4YP9GbRwaoWDy1NwqqrSSgeWnghx+02Fe2gM37WsOPS1s+cHVeiJ7L5 Uk/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=kHgdh3FVMcHl7LeULJBWI5/GWOGSSdMW5TYV3o/H6nA=; b=Pc4ipU/PYrB+YibyYshNo2g9xk1/I6WH1fLuY6E9trn7flbNiSTsSqYjPyNQTBVSGo wMjhvUt1i+xvJASyjFZbw38spwYNlPjbC95TKQLjB+r686jpk0uID4Z1bG5oLEJjR24m Pcedl9Mz75aRCy7l5Wj/KWk+jHX0/XoFsljf6/S73sSJh27148TbD0WPgcR/ch4kz29X CpC8z2efnI5MfVNtsQhpPLhy4sv+tBVGrgqeH+cLDkRul8mHWQdg7A0d0RF3TqSUC+25 dboeLO3w+lXuSKjVpUxO72ZDz7UpaM9Z9Jet9MPBvaMK8xG5Waedw1e25SK1dacZcqU5 LFBw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l33si6172718pld.320.2017.05.18.13.23.08 for ; Thu, 18 May 2017 13:23:08 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-input-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-input-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-input-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755314AbdERUWw (ORCPT ); Thu, 18 May 2017 16:22:52 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:60358 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755384AbdERUWr (ORCPT ); Thu, 18 May 2017 16:22:47 -0400 Received: from wuerfel.lan ([78.42.17.5]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.129]) with ESMTPA (Nemesis) id 0MU9sv-1dcEAW1MP3-00Qj7P; Thu, 18 May 2017 22:22:29 +0200 From: Arnd Bergmann To: Srinivas Pandruvada , Jiri Kosina Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, arnd@arndb.de Subject: [PATCH v2 1/5] HID: intel_ish-hid: fix potential uninitialized data usage Date: Thu, 18 May 2017 22:21:40 +0200 Message-Id: <20170518202144.3482304-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20170518202144.3482304-1-arnd@arndb.de> References: <20170518202144.3482304-1-arnd@arndb.de> X-Provags-ID: V03:K0:JJk82XbVBVDrpf6it6urzSyvm1tT6Y94aVEB155MXiW5GSptAHu c6cAsx6D90ILl1ixTkAHUebWz8b/lHKY4D2iKrR31NPQxHAxhm5R8I7p6Kz/EjgjemNEcjY QlXt7i7c+E1l9on2H+pnlRzv2/x88qPhQ++7PrD9vWUaeCtRJA2fyHFVWmmbdsplTPUCWR7 xNxN9KsJWPp8ssS6S1zRQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:gjT/O9ww4Eg=:BocJOxim9pDXrj4Y7bG/wX CrY9/kFNUiR+vqcCKrLLNNjDi5iAQvB02Gy4J3Js6jnvrw1asHFeHvAApp58/tRbt+7Bu+iK1 56Ga3WwrSWsJJY4vguxxKpZuDZ5RVG5bOkCJhIUZpGu8w0W9TEkJAQRNQ9Wzi2MxeAlAsIzvU nEHkD1lswLwicm3aGSq5ZOTKkbRz9JOHGhJbtmISinavRN3dNBtbkjn+27YnfZnqeLpPYmpKQ fI/GUoIgI/BeszAObfO67lFQ8QDoxPkI/F7z5xGNTLWNCLYJckv7O7XJopbfXVJbbs8N0n290 0z9pl610PRAXZsqB0QUg+UczSuGZPlIFjDrNu0JoNveCeOM+nx2PmWNPPUlby2zt+WSgA0+7a zrSYg3zpoMvm1vnOQT3cof768tt/rKEkznqZDLt0Aa8PXtINarj1rlANW7v/xMXjDlOJhGQRn s2NuBhLdbwfRLnP6HhKMwbbMVnWy3rq2bBmvVLv3c18jEXw6DdpMeSQyyl2KupSXmWsDggDuw HrDiQcW7uA+rC8XNSAGnP7OV5UjgYE+sgqAKwqSUAmTlohimIeOai8BZYhNuOw4oPIMysv70C A+XK+NUTFVM23nGkZ6+1GFvAQQXHHXGjMxGMhdC+MwBbJS8a3XwMkD88kOo7JvpzAEOWPjuFA Dsc3JyfiQxMIdFHKO79DnBttQarpUMK16goJEcTo2Zg7LLgmOEiIPQ8kdvDV/9uu0zL8= Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org gcc points out an uninialized pointer dereference that could happen if we ever get to recv_ishtp_cl_msg_dma() or recv_ishtp_cl_msg() with an empty &dev->read_list: drivers/hid/intel-ish-hid/ishtp/client.c: In function 'recv_ishtp_cl_msg_dma': drivers/hid/intel-ish-hid/ishtp/client.c:1049:3: error: 'cl' may be used uninitialized in this function [-Werror=maybe-uninitialized] The warning only appeared in very few randconfig builds, as the spinlocks tend to prevent gcc from tracing the variables. I only saw it in configurations that had neither SMP nor LOCKDEP enabled. As we can see, we only enter the case if 'complete_rb' is non-NULL, and then 'cl' is known to point to complete_rb->cl. Adding another initialization to the same pointer is harmless here and makes it clear to the compiler that the behavior is well-defined. Signed-off-by: Arnd Bergmann --- drivers/hid/intel-ish-hid/ishtp/client.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/hid/intel-ish-hid/ishtp/client.c b/drivers/hid/intel-ish-hid/ishtp/client.c index aad61328f282..78d393e616a4 100644 --- a/drivers/hid/intel-ish-hid/ishtp/client.c +++ b/drivers/hid/intel-ish-hid/ishtp/client.c @@ -925,6 +925,7 @@ void recv_ishtp_cl_msg(struct ishtp_device *dev, } if (complete_rb) { + cl = complete_rb->cl; getnstimeofday(&cl->ts_rx); ++cl->recv_msg_cnt_ipc; ishtp_cl_read_complete(complete_rb); @@ -1045,6 +1046,7 @@ void recv_ishtp_cl_msg_dma(struct ishtp_device *dev, void *msg, } if (complete_rb) { + cl = complete_rb->cl; getnstimeofday(&cl->ts_rx); ++cl->recv_msg_cnt_dma; ishtp_cl_read_complete(complete_rb);