Skip to content

Commit

Permalink
Input: appletouch - fix DMA to/from stack buffer
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Bob Copeland <me@bobcopeland.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
  • Loading branch information
Bob Copeland authored and Dmitry Torokhov committed Apr 28, 2009
1 parent 384318e commit 0385c5e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions drivers/input/mouse/appletouch.c
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,31 @@ 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");
for (i = 0; i < 8; i++)
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 */
Expand All @@ -281,17 +289,21 @@ 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");
for (i = 0; i < 8; i++)
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;
}

/*
Expand Down

0 comments on commit 0385c5e

Please sign in to comment.