From patchwork Mon Oct 17 22:13:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9380747 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 D5F3460CDC for ; Mon, 17 Oct 2016 22:14:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AEB6328D01 for ; Mon, 17 Oct 2016 22:14:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A39F628CF6; Mon, 17 Oct 2016 22:14:36 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 1612828CFD for ; Mon, 17 Oct 2016 22:14:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758265AbcJQWON (ORCPT ); Mon, 17 Oct 2016 18:14:13 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54607 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758191AbcJQWOH (ORCPT ); Mon, 17 Oct 2016 18:14:07 -0400 Received: from wuerfel.lan. ([78.43.20.153]) by mrelayeu.kundenserver.de (mreue004) with ESMTPA (Nemesis) id 0MHtgv-1bx4Rt3JSH-003cT0; Tue, 18 Oct 2016 00:13:56 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Linus Torvalds , linux-kernel@vger.kernel.org, Arnd Bergmann , Sean Young , Wolfram Sang , Kees Cook , Hans Verkuil , linux-media@vger.kernel.org Subject: [PATCH 13/28] [media] dib0700: fix uninitialized data on 'repeat' event Date: Tue, 18 Oct 2016 00:13:34 +0200 Message-Id: <20161017221355.1861551-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20161017220342.1627073-1-arnd@arndb.de> References: <20161017220342.1627073-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K0:XWM66wv9ik+nUGG9USt4K8EUuZQ3Wul9qLSplTr9PlUec9sCNBZ MisXRu3azgXSb2pftbBkJm5aCf6pPg641QS5XaXrtBdjUgFXmpGY+uEi7vYEu9m9NQk9Bg0 nKaCzS4oD5S13t9kj+agtYHq8lygptNG1rh/iwClfq78jRrDTQa389/+6IiKnxxGrgo7cLA 3+/o6Bm38kcrOnOnhklBQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:R+62l8rVoxA=:t/yoag2heAdlZQaz6FYHo8 z7Sf8IKAWY0ytY7kbGrzcTupP+kGHKvsyE8oL8gn6qTol0uAZU42qADzNYcfMDjH6jYgcOVYk LZQh+umeN683MHuhxXOAvZH7OES9t9dGg1sPPWUac070ERP15XYS6GOgEIOeUNdqklJRs1/76 3y93i9K9mRLhSzIH6bmn2HD6yrtGxDNNV4O4A/BklTGlsf5g70MRh2p0RDKt4XUuR1+8nfEwC GCgWCkwy3s7oMtWbT5rqE9VkI1CbtpCOgFn61HNidAOszyrjGvabf+AHzylm5fElwtqbBfh9+ TJxFTirE2AZ8WPxIX2XYm4kYADFT3pC8ge2ugxL9QVqhjQ7g6uQLEGs9jZe1ctlztPsQDm30q n1gLV6bVvlFCtchR8oxoNPHWrzikgdDT7Jchm8IxwCqddIMP4GCG+ZDTqxcW1SsDuEvLHsvl6 HkEgyGAxZpocz/Hd4E88J2ANOBkGFAA+0qZGKSKX7x3jqQ4RA9+2rflwWYyYUvB0ArmiMk5O/ bNOfn1LHU9BSEtQ4SAMHf90wQA/Z96Sw16ZKiE6Xgwo6J9GSOSJ3NIR7IAk0DX8duC+zlrjAR UMbpLkOUg6w4Xpm1Cs/5cdIW+q1uOE7M8iPCgzYZTwrwFnZzJ/eqKMXmYHmnO9Qn/z8WXZN30 fIqwLo6insxuTdY/QHRpgxpjIfOIehMxCVQZjgPVEGcwbn8/Eb8twC07UwoL1xeVDO6HXKrrR tZavosfq+I9cq5P1 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 After a recent cleanup patch, "gcc -Wmaybe-uninitialized" reports a new warning about an existing bug: drivers/media/usb/dvb-usb/dib0700_core.c: In function ‘dib0700_rc_urb_completion’: drivers/media/usb/dvb-usb/dib0700_core.c:763:2: error: ‘protocol’ may be used uninitialized in this function [-Werror=maybe-uninitialized] It turns out that the "0 0 0 FF" sequence of input data has already caused an uninitialized data use for the keycode variable, but that was hidden with the 'uninitialized_var()' macro. Now, the protocol is also uninitialized. This changes the code to not report any key for this sequence, which fixes both problems, and allows us to also remove the misleading uninitialized_var() annotation. It is possible that we should call rc_repeat() here, but I'm not sure about that. Fixes: 2ceeca0499d7 ("[media] rc: split nec protocol into its three variants") Fixes: d3c501d1938c ("V4L/DVB: dib0700: Fix RC protocol logic to properly handle NEC/NECx and RC-5") Cc: Sean Young Signed-off-by: Arnd Bergmann --- drivers/media/usb/dvb-usb/dib0700_core.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c b/drivers/media/usb/dvb-usb/dib0700_core.c index f319665..3678ebf 100644 --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c @@ -677,7 +677,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) struct dvb_usb_device *d = purb->context; struct dib0700_rc_response *poll_reply; enum rc_type protocol; - u32 uninitialized_var(keycode); + u32 keycode; u8 toggle; deb_info("%s()\n", __func__); @@ -742,11 +742,10 @@ static void dib0700_rc_urb_completion(struct urb *purb) protocol = RC_TYPE_NEC; } + rc_keydown(d->rc_dev, protocol, keycode, toggle); break; default: deb_data("RC5 protocol\n"); - protocol = RC_TYPE_RC5; - toggle = poll_reply->report_id; keycode = RC_SCANCODE_RC5(poll_reply->rc5.system, poll_reply->rc5.data); if ((poll_reply->rc5.data ^ poll_reply->rc5.not_data) != 0xff) { @@ -754,14 +753,13 @@ static void dib0700_rc_urb_completion(struct urb *purb) err("key failed integrity check: %02x %02x %02x %02x", poll_reply->rc5.not_used, poll_reply->rc5.system, poll_reply->rc5.data, poll_reply->rc5.not_data); - goto resubmit; + break; } + rc_keydown(d->rc_dev, RC_TYPE_RC5, keycode, poll_reply->report_id); break; } - rc_keydown(d->rc_dev, protocol, keycode, toggle); - resubmit: /* Clean the buffer before we requeue */ memset(purb->transfer_buffer, 0, RC_MSG_SIZE_V1_20);