From patchwork Tue Nov 9 21:41:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarod Wilson X-Patchwork-Id: 312212 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oA9LfpLH003570 for ; Tue, 9 Nov 2010 21:41:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753584Ab0KIVlt (ORCPT ); Tue, 9 Nov 2010 16:41:49 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44016 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752361Ab0KIVlt (ORCPT ); Tue, 9 Nov 2010 16:41:49 -0500 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id oA9LflTA018455 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 9 Nov 2010 16:41:47 -0500 Received: from xavier.bos.redhat.com (xavier.bos.redhat.com [10.16.16.50]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id oA9LflLK003607; Tue, 9 Nov 2010 16:41:47 -0500 Received: by xavier.bos.redhat.com (Postfix, from userid 500) id 079A7816F7; Tue, 9 Nov 2010 16:41:46 -0500 (EST) Date: Tue, 9 Nov 2010 16:41:46 -0500 From: Jarod Wilson To: linux-media@vger.kernel.org Cc: David =?iso-8859-1?Q?H=E4rdeman?= Subject: [PATCH 2/3 v2] mceusb: buffer parsing fixups for 1st-gen device Message-ID: <20101109214146.GF11073@redhat.com> References: <20101109213921.GD11073@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20101109213921.GD11073@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 09 Nov 2010 21:41:52 +0000 (UTC) diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c index 1811098..ed151c8 100644 --- a/drivers/media/IR/mceusb.c +++ b/drivers/media/IR/mceusb.c @@ -446,7 +446,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) @@ -807,6 +807,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: