c08cca5
From dadfe1ad137e6fbe251b4a5dc310840cfe414db4 Mon Sep 17 00:00:00 2001
c08cca5
From: Josh Boyer <jwboyer@redhat.com>
c08cca5
Date: Mon, 20 Feb 2012 15:28:39 -0500
c08cca5
Subject: [PATCH] ums_realtek: do not use stack memory for DMA in
c08cca5
 __do_config_autodelink
c08cca5
c08cca5
__do_config_autodelink passes the data variable to the transport function.
c08cca5
If the calling functions pass a stack variable, this will eventually trigger
c08cca5
a DMA-API debug backtrace for mapping stack memory in the DMA buffer.  Fix
c08cca5
this by calling kmemdup for the passed data instead.
c08cca5
c08cca5
Signed-off-by: Josh Boyer <jwboyer@redhat.com>
c08cca5
---
c08cca5
 drivers/usb/storage/realtek_cr.c |    8 +++++++-
c08cca5
 1 files changed, 7 insertions(+), 1 deletions(-)
c08cca5
c08cca5
diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
c08cca5
index d32f720..eee2a96 100644
c08cca5
--- a/drivers/usb/storage/realtek_cr.c
c08cca5
+++ b/drivers/usb/storage/realtek_cr.c
c08cca5
@@ -507,9 +507,14 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
c08cca5
 {
c08cca5
 	int retval;
c08cca5
 	u8 cmnd[12] = {0};
c08cca5
+	u8 *buf;
c08cca5
 
c08cca5
 	US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len);
c08cca5
 
c08cca5
+	buf = kmemdup(data, len, GFP_NOIO);
c08cca5
+	if (!buf)
c08cca5
+		return USB_STOR_TRANSPORT_ERROR;
c08cca5
+
c08cca5
 	cmnd[0] = 0xF0;
c08cca5
 	cmnd[1] = 0x0E;
c08cca5
 	cmnd[2] = 0xfe;
c08cca5
@@ -517,7 +522,8 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
c08cca5
 	cmnd[4] = (u8)(len >> 8);
c08cca5
 	cmnd[5] = (u8)len;
c08cca5
 
c08cca5
-	retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, data, len, DMA_TO_DEVICE, NULL);
c08cca5
+	retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, buf, len, DMA_TO_DEVICE, NULL);
c08cca5
+	kfree(buf);
c08cca5
 	if (retval != USB_STOR_TRANSPORT_GOOD) {
c08cca5
 		return -EIO;
c08cca5
 	}
c08cca5
-- 
c08cca5
1.7.9
c08cca5