From patchwork Thu Dec 19 11:32:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 3377411 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D36D2C0D4A for ; Thu, 19 Dec 2013 11:33:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2F2A6204AF for ; Thu, 19 Dec 2013 11:33:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8403920458 for ; Thu, 19 Dec 2013 11:33:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752037Ab3LSLdE (ORCPT ); Thu, 19 Dec 2013 06:33:04 -0500 Received: from mail-ea0-f170.google.com ([209.85.215.170]:53082 "EHLO mail-ea0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751465Ab3LSLdD (ORCPT ); Thu, 19 Dec 2013 06:33:03 -0500 Received: by mail-ea0-f170.google.com with SMTP id k10so415134eaj.1 for ; Thu, 19 Dec 2013 03:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=4EZSHmS4huhQ6F2yOyMgd/B4Wlts/rEB3bBgjUAnzBE=; b=GTc4TmFZF1oVVflms7Rn9xqsxs0yMCFtIHA96Lt2J9aHDJaPAO12UIIb48lg0H7TNt dZxuz9NqBX0j9GMPg2MAb+RdJNd6k9MJ9upTZtlL2DOFE5pKoUU39VXv2sewmRcL47yW LdmrLYLLurCwogN00v90oJDKhL6xfS9TpnDPWOFj+KcHL+bX/mLiIAU7EmGgDDx9EPKA vrkBtmLUaAIKIU7HNBT/KD5bGdXYiaIIOoxXSlT0A2DdvMeQN4Obop2dDOqTcYB0K7TG jfkwXGwX9oLgu55woXE27VbOCiFWTkqX03X9HSO6ocMVwXqp/CwQiJJ8iX+E1Cnz1eiG /Otw== X-Received: by 10.14.47.130 with SMTP id t2mr68275eeb.12.1387452780983; Thu, 19 Dec 2013 03:33:00 -0800 (PST) Received: from localhost.localdomain (stgt-5f719d74.pool.mediaWays.net. [95.113.157.116]) by mx.google.com with ESMTPSA id h48sm8593847eev.3.2013.12.19.03.32.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Dec 2013 03:32:59 -0800 (PST) From: David Herrmann To: linux-input@vger.kernel.org Cc: Jiri Kosina , Dan Carpenter , Joseph Salisbury , "K. Y. Srinivasan" , Haiyang Zhang , linux-kernel@vger.kernel.org, David Herrmann Subject: [PATCH] HID: hyperv: make sure input buffer is big enough Date: Thu, 19 Dec 2013 12:32:24 +0100 Message-Id: <1387452744-8860-1-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.5.1 Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We need at least HID_MAX_BUFFER_SIZE (4096) bytes as input buffer. HID core depends on this as it requires every input report to be at least as big as advertised. Signed-off-by: David Herrmann Signed-off-by: K. Y. Srinivasan --- Hi Same as for the HIDP patch, if there's a way to avoid the extra copy, please provide a better patch. Thanks David drivers/hid/hid-hyperv.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-hyperv.c b/drivers/hid/hid-hyperv.c index 8fae6d1..c24908f 100644 --- a/drivers/hid/hid-hyperv.c +++ b/drivers/hid/hid-hyperv.c @@ -157,6 +157,7 @@ struct mousevsc_dev { u32 report_desc_size; struct hv_input_dev_info hid_dev_info; struct hid_device *hid_device; + u8 input_buf[HID_MAX_BUFFER_SIZE]; }; @@ -256,6 +257,7 @@ static void mousevsc_on_receive(struct hv_device *device, struct synthhid_msg *hid_msg; struct mousevsc_dev *input_dev = hv_get_drvdata(device); struct synthhid_input_report *input_report; + size_t len; pipe_msg = (struct pipe_prt_msg *)((unsigned long)packet + (packet->offset8 << 3)); @@ -300,9 +302,12 @@ static void mousevsc_on_receive(struct hv_device *device, (struct synthhid_input_report *)pipe_msg->data; if (!input_dev->init_complete) break; - hid_input_report(input_dev->hid_device, - HID_INPUT_REPORT, input_report->buffer, - input_report->header.size, 1); + + len = min(input_report->header.size, + (u32)sizeof(input_dev->input_buf)); + memcpy(input_dev->input_buf, input_report->buffer, len); + hid_input_report(input_dev->hid_device, HID_INPUT_REPORT, + input_dev->input_buf, len, 1); break; default: pr_err("unsupported hid msg type - type %d len %d",