linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johannes Berg <johannes@sipsolutions.net>
To: Bob Copeland <me@bobcopeland.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] appletouch: fix DMA to/from stack buffer
Date: Tue, 28 Apr 2009 10:44:54 +0200	[thread overview]
Message-ID: <1240908294.19534.2.camel@johannes.local> (raw)
In-Reply-To: <20090428015844.GA16190@hash.localnet>

[-- Attachment #1: Type: text/plain, Size: 2617 bytes --]

On Mon, 2009-04-27 at 21:58 -0400, Bob Copeland wrote:
> CONFIG_DMA_API_DEBUG spotted an instance of appletouch using
> an array on the stack as a DMA buffer for certain hardware.
> Change it to use a kmalloc()ed buffer instead.
> 
> This fixes the following error:

> Signed-off-by: Bob Copeland <me@bobcopeland.com>

Reviewed-by: Johannes Berg <johannes@sipsolutions.net>

Interestingly, I first thought the GFP_KERNEL is wrong due to
atp_reinit, but the GFP_ATOMIC in that is wrong instead :)

> ---
>  drivers/input/mouse/appletouch.c |   24 ++++++++++++++++++------
>  1 files changed, 18 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/input/mouse/appletouch.c b/drivers/input/mouse/appletouch.c
> index 454b961..e0140fd 100644
> --- a/drivers/input/mouse/appletouch.c
> +++ b/drivers/input/mouse/appletouch.c
> @@ -255,15 +255,22 @@ MODULE_PARM_DESC(debug, "Activate debugging output");
>   */
>  static int atp_geyser_init(struct usb_device *udev)
>  {
> -	char data[8];
> +	char *data;
>  	int size;
>  	int i;
> +	int ret;
> +
> +	data = kmalloc(8, GFP_KERNEL);
> +	if (!data) {
> +		err("Out of memory");
> +		return -ENOMEM;
> +	}
>  
>  	size = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
>  			ATP_GEYSER_MODE_READ_REQUEST_ID,
>  			USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
>  			ATP_GEYSER_MODE_REQUEST_VALUE,
> -			ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
> +			ATP_GEYSER_MODE_REQUEST_INDEX, data, 8, 5000);
>  
>  	if (size != 8) {
>  		dprintk("atp_geyser_init: read error\n");
> @@ -271,7 +278,8 @@ static int atp_geyser_init(struct usb_device *udev)
>  			dprintk("appletouch[%d]: %d\n", i, data[i]);
>  
>  		err("Failed to read mode from device.");
> -		return -EIO;
> +		ret = -EIO;
> +		goto out_free;
>  	}
>  
>  	/* Apply the mode switch */
> @@ -281,7 +289,7 @@ static int atp_geyser_init(struct usb_device *udev)
>  			ATP_GEYSER_MODE_WRITE_REQUEST_ID,
>  			USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
>  			ATP_GEYSER_MODE_REQUEST_VALUE,
> -			ATP_GEYSER_MODE_REQUEST_INDEX, &data, 8, 5000);
> +			ATP_GEYSER_MODE_REQUEST_INDEX, data, 8, 5000);
>  
>  	if (size != 8) {
>  		dprintk("atp_geyser_init: write error\n");
> @@ -289,9 +297,13 @@ static int atp_geyser_init(struct usb_device *udev)
>  			dprintk("appletouch[%d]: %d\n", i, data[i]);
>  
>  		err("Failed to request geyser raw mode");
> -		return -EIO;
> +		ret = -EIO;
> +		goto out_free;
>  	}
> -	return 0;
> +	ret = 0;
> +out_free:
> +	kfree(data);
> +	return ret;
>  }
>  
>  /*
> -- 
> 1.6.0.6
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2009-04-28  8:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-28  1:58 [PATCH] appletouch: fix DMA to/from stack buffer Bob Copeland
2009-04-28  8:44 ` Johannes Berg [this message]
2009-05-01 13:36   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1240908294.19534.2.camel@johannes.local \
    --to=johannes@sipsolutions.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=me@bobcopeland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).