From patchwork Mon Apr 24 08:13:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maksim Salau X-Patchwork-Id: 9695815 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8ED3C601AE for ; Mon, 24 Apr 2017 08:14:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DF78201BD for ; Mon, 24 Apr 2017 08:14:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 72ABB26C9B; Mon, 24 Apr 2017 08:14:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17BFD201BD for ; Mon, 24 Apr 2017 08:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1166482AbdDXIOP (ORCPT ); Mon, 24 Apr 2017 04:14:15 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36635 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1166546AbdDXIOG (ORCPT ); Mon, 24 Apr 2017 04:14:06 -0400 Received: by mail-lf0-f67.google.com with SMTP id 75so15304444lfs.3 for ; Mon, 24 Apr 2017 01:14:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=NHrB6uOMO7/f9B76MO5JBbIVhV6Ha2MiB+VPrtnzqA0=; b=Wd150jd311ic5knGEcS+VF+dpehn59SJoNVROPmuKvr6Nvx4FX9N2OF2Cr07xT9ulK 8RYF4eckne6J9vQ/o58jPEPgKi1wuJZnL8mQd35+/Mvjc3iU79fJ2/jUCNg/XEUOVAVh AH7MIubuwAOrUYXoq4ip3lBJPsOi6s3Da9I9U5VKQvkZtUvF+LXdrcS2K0/21alvdB9z QBR+VN0/NNiHuLTt3uLpZrQdZTBEJmynxWsfKvmp4XS+RPm0/zbzAula7xC/5T6iYm3J Fo/vVBvVz3Shnhc4LAKYNSPfLxa0BOgv+LhZ02Ool8sn7wy7MxoiWqVHf4LJA7TJ4dOw 6iZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=NHrB6uOMO7/f9B76MO5JBbIVhV6Ha2MiB+VPrtnzqA0=; b=frneNu1ggysAn+IYn28z3qTuqhPurDWdpk+vxoMVw/DemkUZx0YsHQHdrwhLaeYGU/ l+XFnz3aw27aHJNLGTngo4enc4wsqI0/9HNtTbl2cwh1PCPQg+ublo0eDuL0vsBFdMjK VqdNW1pVGqoh00gMYPVJ0+Ibifd+uEwpKUZoPCvWfMP/nTU4ffrY9vzj+RRTuEMabyU4 Q18HFoPtEDY42w3hcSAq0H54tpnlqYLvcC1in5J2z4hKkIvoIYFKHE51MA7AyxVVNP8O UswpFJFXYuLrz6tGuqHQVvGsOCcfYg4zOuhuuSdqhn1xNEyByjAXC5iHfmw7zZ4lxE8c HV3Q== X-Gm-Message-State: AN3rC/4whPnw90NA5vJuqDN1Lr0/pfb24Qf6JUu8/lj7tJ57MT8CvTwy i01skpWa7p/s+A== X-Received: by 10.25.169.129 with SMTP id s123mr8069763lfe.119.1493021644802; Mon, 24 Apr 2017 01:14:04 -0700 (PDT) Received: from localhost.localdomain (nat2-minsk-pool-46-53-195-202.telecom.by. [46.53.195.202]) by smtp.googlemail.com with ESMTPSA id o81sm3126175lfi.33.2017.04.24.01.14.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Apr 2017 01:14:03 -0700 (PDT) From: Maksim Salau To: Bernie Thompson , Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org, Geert Uytterhoeven Cc: Maksim Salau Subject: [PATCH v2] video: fbdev: udlfb: Fix buffer on stack Date: Mon, 24 Apr 2017 11:13:49 +0300 Message-Id: <20170424081349.26152-1-maksim.salau@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170424110605.2366eb8f@gmail.com> References: <20170424110605.2366eb8f@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allocate buffers on HEAP instead of STACK for local array that is to be sent using usb_control_msg(). Signed-off-by: Maksim Salau --- Changes in v2: declared set_def_chn as 'static const' to avoid double copying; replaced allocation and copying with a single call to kmemdup. drivers/video/fbdev/udlfb.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index e9c2f7b..6a3c353 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1487,15 +1487,25 @@ static struct device_attribute fb_device_attrs[] = { static int dlfb_select_std_channel(struct dlfb_data *dev) { int ret; - u8 set_def_chn[] = { 0x57, 0xCD, 0xDC, 0xA7, + void *buf; + static const u8 set_def_chn[] = { + 0x57, 0xCD, 0xDC, 0xA7, 0x1C, 0x88, 0x5E, 0x15, 0x60, 0xFE, 0xC6, 0x97, 0x16, 0x3D, 0x47, 0xF2 }; + buf = kmemdup(set_def_chn, sizeof(set_def_chn), GFP_KERNEL); + + if (!buf) + return -ENOMEM; + ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), NR_USB_REQUEST_CHANNEL, (USB_DIR_OUT | USB_TYPE_VENDOR), 0, 0, - set_def_chn, sizeof(set_def_chn), USB_CTRL_SET_TIMEOUT); + buf, sizeof(set_def_chn), USB_CTRL_SET_TIMEOUT); + + kfree(buf); + return ret; }