From: Sergei Shtylyov <sshtylyov@mvista.com>
To: Adam Cozzette <acozzette@cs.hmc.edu>
Cc: Greg Kroah-Hartman <gregkh@suse.de>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
Josh Boyer <jwboyer@redhat.com>,
edwin_rong <edwin_rong@realsil.com.cn>,
wwang <wei_wang@realsil.com.cn>
Subject: Re: [PATCH] ums_realtek: do not use stack memory for DMA
Date: Thu, 25 Aug 2011 14:51:51 +0400 [thread overview]
Message-ID: <4E562947.3000304@ru.mvista.com> (raw)
In-Reply-To: <20110824182237.GC5450@[192.168.0.12]>
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
prev parent reply other threads:[~2011-08-25 10:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-24 18:22 [PATCH] ums_realtek: do not use stack memory for DMA Adam Cozzette
2011-08-25 10:51 ` Sergei Shtylyov [this message]
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=4E562947.3000304@ru.mvista.com \
--to=sshtylyov@mvista.com \
--cc=acozzette@cs.hmc.edu \
--cc=edwin_rong@realsil.com.cn \
--cc=gregkh@suse.de \
--cc=jwboyer@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=wei_wang@realsil.com.cn \
/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