From patchwork Mon Apr 12 18:16:11 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pete Zaitcev X-Patchwork-Id: 92066 X-Patchwork-Delegate: jikos@jikos.cz Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o3CIGB8H019124 for ; Mon, 12 Apr 2010 18:16:11 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753272Ab0DLSQK (ORCPT ); Mon, 12 Apr 2010 14:16:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55069 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057Ab0DLSQJ convert rfc822-to-8bit (ORCPT ); Mon, 12 Apr 2010 14:16:09 -0400 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 o3CIG5xE017779 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 12 Apr 2010 14:16:05 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o3CIG4Ki011110; Mon, 12 Apr 2010 14:16:04 -0400 Received: from localhost (vpn-236-253.phx2.redhat.com [10.3.236.253]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id o3CIG2lV002662; Mon, 12 Apr 2010 14:16:03 -0400 Date: Mon, 12 Apr 2010 12:16:11 -0600 From: Pete Zaitcev To: Jiri Kosina Cc: linux-input@vger.kernel.org, zaitcev@redhat.com Subject: [Patch] HID: non-overlapping zeroing of extra bits Message-ID: <20100412121611.4d8ff409@redhat.com> Organization: Red Hat, Inc. Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.67 on 10.5.11.12 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 12 Apr 2010 18:16:11 +0000 (UTC) diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c @@ -940,13 +940,8 @@ static void hid_output_field(struct hid_field *field, __u8 *data) unsigned count = field->report_count; unsigned offset = field->report_offset; unsigned size = field->report_size; - unsigned bitsused = offset + count * size; unsigned n; - /* make sure the unused bits in the last byte are zeros */ - if (count > 0 && size > 0 && (bitsused % 8) != 0) - data[(bitsused-1)/8] &= (1 << (bitsused % 8)) - 1; - for (n = 0; n < count; n++) { if (field->logical_minimum < 0) /* signed values */ implement(data, offset + n * size, size, s32ton(field->value[n], size)); @@ -966,6 +961,7 @@ void hid_output_report(struct hid_report *report, __u8 *data) if (report->id > 0) *data++ = report->id; + memset(data, 0, ((report->size - 1) >> 3) + 1); for (n = 0; n < report->maxfield; n++) hid_output_field(report->field[n], data); }