[kernel] Avoid using stack variables in ums_realtek (again) (rhbz 795544)

Josh Boyer jwboyer at fedoraproject.org
Mon Feb 20 21:49:03 UTC 2012


commit c10e53789bf2d500b01ff7f9cb94ac4d9c22ef5f
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Mon Feb 20 16:20:25 2012 -0500

    Avoid using stack variables in ums_realtek (again) (rhbz 795544)

 kernel.spec                                        |   13 +++++-
 ...-do-not-use-stack-memory-for-DMA-in-__do_.patch |   48 ++++++++++++++++++++
 2 files changed, 59 insertions(+), 2 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index dbe3b2d..80fc7b9 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -772,6 +772,9 @@ Patch21238: x86-Avoid-invoking-RCU-when-CPU-is-idle.patch
 #rhbz 790367
 Patch21239: s390x-enable-keys-compat.patch
 
+#rhbz 795544
+Patch21240: ums_realtek-do-not-use-stack-memory-for-DMA-in-__do_.patch
+
 # compat-wireless patches
 Patch50000: compat-wireless-config-fixups.patch
 Patch50001: compat-wireless-pr_fmt-warning-avoidance.patch
@@ -1492,6 +1495,9 @@ ApplyPatch x86-Avoid-invoking-RCU-when-CPU-is-idle.patch
 #rhbz 790367
 ApplyPatch s390x-enable-keys-compat.patch
 
+#rhbz 795544
+ApplyPatch ums_realtek-do-not-use-stack-memory-for-DMA-in-__do_.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2370,13 +2376,16 @@ fi
 #                 ||----w |
 #                 ||     ||
 %changelog
+* Mon Feb 20 2012 Josh Boyer <jwboyer at redhat.com>
+- Avoid using stack variables in ums_realtek (again) (rhbz 795544)
+
 * Mon Feb 20 2012 Dave Jones <davej at redhat.com>
 - NFSv4: Fix an Oops in the NFSv4 getacl code
 
-* Mon Feb 20 2012 Josh Boyer <jwboyer at gmail.com> - 3.3.0-0.rc4.git0.2
+* Mon Feb 20 2012 Josh Boyer <jwboyer at redhat.com> - 3.3.0-0.rc4.git0.2
 - Reenable debugging options.
 
-* Sun Feb 19 2012 Josh Boyer <jwboyer at gmail.com> - 3.3.0-0.rc4.git0.1
+* Sun Feb 19 2012 Josh Boyer <jwboyer at redhat.com> - 3.3.0-0.rc4.git0.1
 - Linux 3.3-rc4
 - Disable debugging options.
 
diff --git a/ums_realtek-do-not-use-stack-memory-for-DMA-in-__do_.patch b/ums_realtek-do-not-use-stack-memory-for-DMA-in-__do_.patch
new file mode 100644
index 0000000..1768d5e
--- /dev/null
+++ b/ums_realtek-do-not-use-stack-memory-for-DMA-in-__do_.patch
@@ -0,0 +1,48 @@
+From dadfe1ad137e6fbe251b4a5dc310840cfe414db4 Mon Sep 17 00:00:00 2001
+From: Josh Boyer <jwboyer at redhat.com>
+Date: Mon, 20 Feb 2012 15:28:39 -0500
+Subject: [PATCH] ums_realtek: do not use stack memory for DMA in
+ __do_config_autodelink
+
+__do_config_autodelink passes the data variable to the transport function.
+If the calling functions pass a stack variable, this will eventually trigger
+a DMA-API debug backtrace for mapping stack memory in the DMA buffer.  Fix
+this by calling kmemdup for the passed data instead.
+
+Signed-off-by: Josh Boyer <jwboyer at redhat.com>
+---
+ drivers/usb/storage/realtek_cr.c |    8 +++++++-
+ 1 files changed, 7 insertions(+), 1 deletions(-)
+
+diff --git a/drivers/usb/storage/realtek_cr.c b/drivers/usb/storage/realtek_cr.c
+index d32f720..eee2a96 100644
+--- a/drivers/usb/storage/realtek_cr.c
++++ b/drivers/usb/storage/realtek_cr.c
+@@ -507,9 +507,14 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
+ {
+ 	int retval;
+ 	u8 cmnd[12] = {0};
++	u8 *buf;
+ 
+ 	US_DEBUGP("%s, addr = 0xfe47, len = %d\n", __FUNCTION__, len);
+ 
++	buf = kmemdup(data, len, GFP_NOIO);
++	if (!buf)
++		return USB_STOR_TRANSPORT_ERROR;
++
+ 	cmnd[0] = 0xF0;
+ 	cmnd[1] = 0x0E;
+ 	cmnd[2] = 0xfe;
+@@ -517,7 +522,8 @@ static int __do_config_autodelink(struct us_data *us, u8 *data, u16 len)
+ 	cmnd[4] = (u8)(len >> 8);
+ 	cmnd[5] = (u8)len;
+ 
+-	retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, data, len, DMA_TO_DEVICE, NULL);
++	retval = rts51x_bulk_transport_special(us, 0, cmnd, 12, buf, len, DMA_TO_DEVICE, NULL);
++	kfree(buf);
+ 	if (retval != USB_STOR_TRANSPORT_GOOD) {
+ 		return -EIO;
+ 	}
+-- 
+1.7.9
+


More information about the scm-commits mailing list