From patchwork Tue May 4 12:14:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 96723 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o44CEkRH025662 for ; Tue, 4 May 2010 12:14:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757859Ab0EDMOn (ORCPT ); Tue, 4 May 2010 08:14:43 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:56685 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752137Ab0EDMOl (ORCPT ); Tue, 4 May 2010 08:14:41 -0400 Received: by fxm10 with SMTP id 10so3133468fxm.19 for ; Tue, 04 May 2010 05:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:mime-version:content-type:content-disposition:user-agent; bh=kNhqZyYRplt/glCW8Yy3qdaf94r/FCtx394v3mDmJao=; b=bTs/UgKs0TNAW3q+LFntzcuz84OYJTwEWGyYlTKCPfrN0FJsF/rZQMA5yNPTouTy/t G/UZ0VCV5mtbhPHLGtPJMNBcHHAIaZ5aEhosXIvsOSBceZTrxacFOBwZqTNCVnxpriKB TGThTsop+4nOSuA0bTd7KxIN7XnQoLJUjvMEE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; b=tHU5i9bGydo8e+hrHxEUw0upMe4YQeTy8uPq9OExicwROjHVAwCyDfHiO98a1O5oPE tRqTQoqBYOCDg3GHM1G96fUtY1/t+YqRnodCvDJnxBXlSuom0MHfFsQcREBkLQNJnIhb IOhnnuMGLBk4cTakZVprrfgbZnbptS+eSHZo4= Received: by 10.223.47.130 with SMTP id n2mr4054145faf.55.1272975277473; Tue, 04 May 2010 05:14:37 -0700 (PDT) Received: from bicker ([205.177.176.130]) by mx.google.com with ESMTPS id p17sm11180557fka.16.2010.05.04.05.14.32 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 04 May 2010 05:14:36 -0700 (PDT) Date: Tue, 4 May 2010 14:14:29 +0200 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Adams.xu@azwave.com.cn, linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch -next 1/2] media/az6027: doing dma on the stack Message-ID: <20100504121429.GW29093@bicker> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) 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.3 (demeter.kernel.org [140.211.167.41]); Tue, 04 May 2010 12:14:47 +0000 (UTC) diff --git a/drivers/media/dvb/dvb-usb/az6027.c b/drivers/media/dvb/dvb-usb/az6027.c index 8934788..baaa301 100644 --- a/drivers/media/dvb/dvb-usb/az6027.c +++ b/drivers/media/dvb/dvb-usb/az6027.c @@ -417,11 +417,15 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, u16 value; u16 index; int blen; - u8 b[12]; + u8 *b; if (slot != 0) return -EINVAL; + b = kmalloc(12, GFP_KERNEL); + if (!b) + return -ENOMEM; + mutex_lock(&state->ca_mutex); req = 0xC1; @@ -438,6 +442,7 @@ static int az6027_ci_read_attribute_mem(struct dvb_ca_en50221 *ca, } mutex_unlock(&state->ca_mutex); + kfree(b); return ret; } @@ -485,11 +490,15 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, u16 value; u16 index; int blen; - u8 b[12]; + u8 *b; if (slot != 0) return -EINVAL; + b = kmalloc(12, GFP_KERNEL); + if (!b) + return -ENOMEM; + mutex_lock(&state->ca_mutex); req = 0xC3; @@ -510,6 +519,7 @@ static int az6027_ci_read_cam_control(struct dvb_ca_en50221 *ca, } mutex_unlock(&state->ca_mutex); + kfree(b); return ret; } @@ -556,7 +566,11 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot) u16 value; u16 index; int blen; - u8 b[12]; + u8 *b; + + b = kmalloc(12, GFP_KERNEL); + if (!b) + return -ENOMEM; req = 0xC8; value = 0; @@ -570,6 +584,7 @@ static int CI_CamReady(struct dvb_ca_en50221 *ca, int slot) } else{ ret = b[0]; } + kfree(b); return ret; } @@ -667,8 +682,11 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o u16 value; u16 index; int blen; - u8 b[12]; + u8 *b; + b = kmalloc(12, GFP_KERNEL); + if (!b) + return -ENOMEM; mutex_lock(&state->ca_mutex); req = 0xC5; @@ -692,6 +710,7 @@ static int az6027_ci_poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int o } mutex_unlock(&state->ca_mutex); + kfree(b); return ret; } @@ -943,10 +962,16 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n u16 value; int length; u8 req; - u8 data[256]; + u8 *data; + + data = kmalloc(256, GFP_KERNEL); + if (!data) + return -ENOMEM; - if (mutex_lock_interruptible(&d->i2c_mutex) < 0) + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) { + kfree(data); return -EAGAIN; + } if (num > 2) warn("more than 2 i2c messages at a time is not handled yet. TODO."); @@ -1016,6 +1041,7 @@ static int az6027_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[], int n } } mutex_unlock(&d->i2c_mutex); + kfree(data); return i; } @@ -1036,8 +1062,14 @@ int az6027_identify_state(struct usb_device *udev, struct dvb_usb_device_description **desc, int *cold) { - u8 b[16]; - s16 ret = usb_control_msg(udev, + u8 *b; + s16 ret; + + b = kmalloc(16, GFP_KERNEL); + if (!b) + return -ENOMEM; + + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0xb7, USB_TYPE_VENDOR | USB_DIR_IN, @@ -1048,7 +1080,7 @@ int az6027_identify_state(struct usb_device *udev, USB_CTRL_GET_TIMEOUT); *cold = ret <= 0; - + kfree(b); deb_info("cold: %d\n", *cold); return 0; }