From patchwork Mon Mar 28 13:22:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josh Boyer X-Patchwork-Id: 8679271 Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 012159F44D for ; Mon, 28 Mar 2016 13:22:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 221B620107 for ; Mon, 28 Mar 2016 13:22:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 38D0520123 for ; Mon, 28 Mar 2016 13:22:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753899AbcC1NWb (ORCPT ); Mon, 28 Mar 2016 09:22:31 -0400 Received: from mail-qk0-f171.google.com ([209.85.220.171]:34705 "EHLO mail-qk0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753357AbcC1NWb (ORCPT ); Mon, 28 Mar 2016 09:22:31 -0400 Received: by mail-qk0-f171.google.com with SMTP id x64so69599170qkd.1; Mon, 28 Mar 2016 06:22:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=9oxo6++s5klYVXLY0Cz9sG2uu9dQBw1URJ0b/OTq7K4=; b=x2ucoyMQq7BM2+vgAfrmyiRhDXagWmrwfcOIZ3916IrNl8ln+BrjKbdVElRUlI9ikx zHZVUnMXfQjw6Wr5Psvem98QzPt942fHJzHjnFen6s3KJR5mW0pUOt6/chiveURo4uwk CXFNqo9dwAHQiIBVUs8EJOTkXozUFOPHgOWfJzbRcliiDnDQUVzh6n3qrmMt8jvoHsEv U51qK5Htv6UUIxAef8u0YxSlEkIh0UB3bpshPqlaH/+G2WJJuUMhSjHj11UGjaSc7Yd1 IJT1OfV3s3YYONwFMpikg5g7A9F+u1MwTAgFmQfcB/3MHEbmCO0YIqejTUSTLh6vZVFm gQ+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9oxo6++s5klYVXLY0Cz9sG2uu9dQBw1URJ0b/OTq7K4=; b=Z4ueIDl2EwvZWugbc9KQ1sewUQe/C8DfAVN1YIO+r+7ANeuGbMMtSQixzJxjimTCri Os/95f3TnUYnOhAAQTdNmGJxykvVvfGdQY+QJPjnFYFcEm8ma3sNzeFEQJaJIeM60Mud rS4bJ3ZqO/6uLiTOWuglRktYiANpGv2+DqRxfMasArl36M3AMgsq/xoexWIdofvMvsmi YCmMOtAsQ106K7VIJy75/JOFTsaW3GsxtuNyTpG23M91APEbEiEmdKy6sNP6E1hLrdm0 N+64Ziojwt0ucM24Zx9xyGRtpGm+hNotNzCq7paLDgo58WFPVuKurdd8MZd8nRIFTVbS Zzkg== X-Gm-Message-State: AD7BkJI7xsZfWDiRbAI8meCyIjJ9uXdZoJIP1CN3MluslNOTdDGeeAPKzmWAJGI1CjCwHQ== X-Received: by 10.129.35.6 with SMTP id j6mr13537995ywj.133.1459171349931; Mon, 28 Mar 2016 06:22:29 -0700 (PDT) Received: from vader.localdomain (24-247-110-74.dhcp.aldl.mi.charter.com. [24.247.110.74]) by smtp.gmail.com with ESMTPSA id p189sm16543745ywc.44.2016.03.28.06.22.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Mar 2016 06:22:29 -0700 (PDT) From: Josh Boyer To: Jiri Kosina , Benjamin Tissoires Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] HID: lenovo: Don't use stack variables for DMA buffers Date: Mon, 28 Mar 2016 09:22:14 -0400 Message-Id: <1459171334-22943-2-git-send-email-jwboyer@fedoraproject.org> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1459171334-22943-1-git-send-email-jwboyer@fedoraproject.org> References: <1459171334-22943-1-git-send-email-jwboyer@fedoraproject.org> 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.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 The lenovo_send_cmd_cptkbd function uses a stack variable to submit commands via hid_hw_raw_request. Eventually this gets to the usb_hcd_map_urb_for_dma function, which causes a warning to be thrown if the CONFIG_DMA_API_DEBUG option is enabled. Fix this by allocating a temporary buffer instead. Reported-by: lejeczek Signed-off-by: Josh Boyer Reviewed-by: Benjamin Tissoires --- drivers/hid/hid-lenovo.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-lenovo.c b/drivers/hid/hid-lenovo.c index 0125e356bd8d..2ba5e8ea66a4 100644 --- a/drivers/hid/hid-lenovo.c +++ b/drivers/hid/hid-lenovo.c @@ -184,21 +184,31 @@ static int lenovo_send_cmd_cptkbd(struct hid_device *hdev, unsigned char byte2, unsigned char byte3) { int ret; - unsigned char buf[] = {0x18, byte2, byte3}; + unsigned char *buf = NULL; + + buf = kzalloc(3, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + buf[0] = 0x18; + buf[1] = byte2; + buf[2] = byte3; switch (hdev->product) { case USB_DEVICE_ID_LENOVO_CUSBKBD: - ret = hid_hw_raw_request(hdev, 0x13, buf, sizeof(buf), + ret = hid_hw_raw_request(hdev, 0x13, buf, 3, HID_FEATURE_REPORT, HID_REQ_SET_REPORT); break; case USB_DEVICE_ID_LENOVO_CBTKBD: - ret = hid_hw_output_report(hdev, buf, sizeof(buf)); + ret = hid_hw_output_report(hdev, buf, 3); break; default: ret = -EINVAL; break; } + kfree(buf); + return ret < 0 ? ret : 0; /* BT returns 0, USB returns sizeof(buf) */ }