From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Carpenter Subject: Re: [PATCH 1/1] Drivers: input: serio: New driver to support Hyper-V synthetic keyboard Date: Mon, 16 Sep 2013 21:33:19 +0300 Message-ID: <20130916183319.GM19256@mwanda> References: <1379309334-25042-1-git-send-email-kys@microsoft.com> <20130916082110.GN25896@mwanda> <3b5096d0190b4440a8e25afbd22ab72d@SN2PR03MB061.namprd03.prod.outlook.com> <20130916150548.GO25896@mwanda> <20130916170951.GB20734@core.coreip.homeip.net> <3e45f054c6e243eabf2896ab1dcf38d4@SN2PR03MB061.namprd03.prod.outlook.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from aserp1040.oracle.com ([141.146.126.69]:43758 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751921Ab3IPShK (ORCPT ); Mon, 16 Sep 2013 14:37:10 -0400 Content-Disposition: inline In-Reply-To: <3e45f054c6e243eabf2896ab1dcf38d4@SN2PR03MB061.namprd03.prod.outlook.com> Sender: linux-input-owner@vger.kernel.org List-Id: linux-input@vger.kernel.org To: KY Srinivasan Cc: Dmitry Torokhov , "olaf@aepfle.de" , "gregkh@linuxfoundation.org" , "jasowang@redhat.com" , "linux-kernel@vger.kernel.org" , "vojtech@suse.cz" , "linux-input@vger.kernel.org" , "apw@canonical.com" , "devel@linuxdriverproject.org" Just roll something like the following into your patch. regards, dan carpenter diff --git a/drivers/input/serio/hyperv-keyboard.c b/drivers/input/serio/hyperv-keyboard.c index 0d4625f..262721b 100644 --- a/drivers/input/serio/hyperv-keyboard.c +++ b/drivers/input/serio/hyperv-keyboard.c @@ -151,15 +151,18 @@ static void hv_kbd_free_device(struct hv_kbd_dev *device) } static void hv_kbd_on_receive(struct hv_device *device, - struct vmpacket_descriptor *packet) + struct vmpacket_descriptor *packet, size_t size) { struct synth_kbd_msg *msg; struct hv_kbd_dev *kbd_dev = hv_get_drvdata(device); struct synth_kbd_keystroke *ks_msg; + int offset; u16 scan_code; - msg = (struct synth_kbd_msg *)((unsigned long)packet + - (packet->offset8 << 3)); + offset = packet->offset8 << 3; + if (offset + sizeof(struct synth_kbd_protocol_response) > size) + return; + msg = (void *)packet + offset; switch (msg->header.type) { case SYNTH_KBD_PROTOCOL_RESPONSE: @@ -220,7 +223,7 @@ static void hv_kbd_on_channel_callback(void *context) break; case VM_PKT_DATA_INBAND: - hv_kbd_on_receive(device, desc); + hv_kbd_on_receive(device, desc, bytes_recvd); break; default: