From patchwork Fri Oct 29 03:08:42 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 4750 Return-path: Envelope-to: mchehab@pedra Delivery-date: Fri, 29 Oct 2010 09:11:32 -0200 Received: from mchehab by pedra with local (Exim 4.72) (envelope-from ) id 1PBmrr-0001GO-GH for mchehab@pedra; Fri, 29 Oct 2010 09:11:31 -0200 Received: from casper.infradead.org [85.118.1.10] by pedra with IMAP (fetchmail-6.3.17) for (single-drop); Fri, 29 Oct 2010 09:11:31 -0200 (BRST) Received: from vger.kernel.org ([209.132.180.67]) by casper.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1PBfKe-0006oE-PN; Fri, 29 Oct 2010 03:08:45 +0000 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760162Ab0J2DIn (ORCPT + 1 other); Thu, 28 Oct 2010 23:08:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:30663 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756106Ab0J2DIn (ORCPT ); Thu, 28 Oct 2010 23:08:43 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o9T38gxJ008146 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 28 Oct 2010 23:08:43 -0400 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o9T38gd1020465 for ; Thu, 28 Oct 2010 23:08:42 -0400 Received: by xavier.bos.redhat.com (Postfix, from userid 500) id 89E08815D6; Thu, 28 Oct 2010 23:08:42 -0400 (EDT) Date: Thu, 28 Oct 2010 23:08:42 -0400 From: Jarod Wilson To: linux-media@vger.kernel.org Subject: [PATCH 3/3] mceusb: buffer parsing fixups for 1st-gen device Message-ID: <20101029030842.GD17238@redhat.com> References: <20101029030545.GA17238@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101029030545.GA17238@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Sender: If we pass in an offset, we shouldn't skip 2 bytes. And the first-gen hardware generates a constant stream of interrupts, always with two header bytes, and if there's been no IR, with nothing else. Bail from ir processing without calling ir_handle_raw_event when we get such a buffer delivered to us. Signed-off-by: Jarod Wilson --- drivers/media/IR/mceusb.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-) diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index a05dec7..09a62f1 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c @@ -445,7 +445,7 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, char *buf, return; /* skip meaningless 0xb1 0x60 header bytes on orig receiver */ - if (ir->flags.microsoft_gen1 && !out) + if (ir->flags.microsoft_gen1 && !out && !offset) skip = 2; if (len <= skip) @@ -806,6 +806,10 @@ static void mceusb_process_ir_data(struct mceusb_dev *ir, int buf_len) if (ir->flags.microsoft_gen1) i = 2; + /* if there's no data, just return now */ + if (buf_len <= i) + return; + for (; i < buf_len; i++) { switch (ir->parser_state) { case SUBCMD: