From patchwork Sun Mar 20 21:50:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Mickler X-Patchwork-Id: 646851 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2KLqqgY020078 for ; Sun, 20 Mar 2011 21:52:53 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751749Ab1CTVvf (ORCPT ); Sun, 20 Mar 2011 17:51:35 -0400 Received: from ist.d-labs.de ([213.239.218.44]:51941 "EHLO mx01.d-labs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751043Ab1CTVvc (ORCPT ); Sun, 20 Mar 2011 17:51:32 -0400 Received: from schatten.dmk.lab (f053218247.adsl.alicedsl.de [78.53.218.247]) by mx01.d-labs.de (Postfix) with ESMTPSA id 224817F8EB; Sun, 20 Mar 2011 22:51:29 +0100 (CET) Received: by schatten.dmk.lab (Postfix, from userid 1000) id A669A18443; Sun, 20 Mar 2011 22:51:12 +0100 (CET) From: Florian Mickler To: mchehab@infradead.org Cc: linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, crope@iki.fi, tvboxspy@gmail.com, Florian Mickler Subject: [PATCH 1/5] [media] ec168: get rid of on-stack dma buffers Date: Sun, 20 Mar 2011 22:50:48 +0100 Message-Id: <1300657852-29318-2-git-send-email-florian@mickler.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1300657852-29318-1-git-send-email-florian@mickler.org> References: <1300657852-29318-1-git-send-email-florian@mickler.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 20 Mar 2011 21:52:53 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-usb/ec168.c b/drivers/media/dvb/dvb-usb/ec168.c index 52f5d4f..1ba3e5d 100644 --- a/drivers/media/dvb/dvb-usb/ec168.c +++ b/drivers/media/dvb/dvb-usb/ec168.c @@ -36,7 +36,9 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) int ret; unsigned int pipe; u8 request, requesttype; - u8 buf[req->size]; + u8 *buf; + + switch (req->cmd) { case DOWNLOAD_FIRMWARE: @@ -72,6 +74,12 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) goto error; } + buf = kmalloc(req->size, GFP_KERNEL); + if (!buf) { + ret = -ENOMEM; + goto error; + } + if (requesttype == (USB_TYPE_VENDOR | USB_DIR_OUT)) { /* write */ memcpy(buf, req->data, req->size); @@ -84,13 +92,13 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) msleep(1); /* avoid I2C errors */ ret = usb_control_msg(udev, pipe, request, requesttype, req->value, - req->index, buf, sizeof(buf), EC168_USB_TIMEOUT); + req->index, buf, req->size, EC168_USB_TIMEOUT); ec168_debug_dump(request, requesttype, req->value, req->index, buf, req->size, deb_xfer); if (ret < 0) - goto error; + goto err_dealloc; else ret = 0; @@ -98,7 +106,11 @@ static int ec168_rw_udev(struct usb_device *udev, struct ec168_req *req) if (!ret && requesttype == (USB_TYPE_VENDOR | USB_DIR_IN)) memcpy(req->data, buf, req->size); + kfree(buf); return ret; + +err_dealloc: + kfree(buf); error: deb_info("%s: failed:%d\n", __func__, ret); return ret;