lkml.org 
[lkml]   [2011]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] ums_realtek: do not use stack memory for DMA
Hello.

On 24-08-2011 22:22, Adam Cozzette wrote:

> This patch changes rts51x_read_mem, rts51x_write_mem, and rts51x_read_status to
> allocate temporary buffers with kmalloc. This way stack addresses are not used
> for DMA when these functions call rts51x_bulk_transport.

> Signed-off-by: Adam Cozzette<acozzette@cs.hmc.edu>
> ---
> realtek_cr.c | 35 ++++++++++++++++++++++++++++++-----
> 1 file changed, 30 insertions(+), 5 deletions(-)

> diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
> index 34adc4b..232167a 100644
> --- a/drivers/usb/storage/realtek_cr.c
> +++ b/drivers/usb/storage/realtek_cr.c
[...]
> @@ -342,6 +351,12 @@ static int rts51x_write_mem(struct us_data *us, u16 addr, u8 *data, u16 len)
> {
> int retval;
> u8 cmnd[12] = { 0 };
> + u8 *buf;
> +
> + buf = kmalloc(len, GFP_NOIO);
> + if (buf == NULL)
> + return USB_STOR_TRANSPORT_ERROR;
> + memcpy(buf, data, len);

You could use kmemdup() instead of kmalloc()/memcpy()...

WBR, Sergei


\
 
 \ /
  Last update: 2011-08-25 12:55    [W:4.365 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site