the following error pops up during "testusb -a -t 10"
| musb-hdrc musb-hdrc.1.auto: dma_pool_free buffer-128, f134e000/be842000 (bad 
dma)

hcd_buffer_create() creates a few buffers, the smallest has 32 bytes of
size. ARCH_KMALLOC_MINALIGN is set to 64 bytes. This combo results in
hcd_buffer_alloc() returning memory which is 32bytes aligned and it
might by identified by buffer_offset() as another buffer. This means the
buffer which is on a 32byte boundary will not get freed, instead it
tries to free another buffer with the error message.

This patch fixes the issue by checking only if the lowest bit is set
which is the only "unaligned" offset which is currently passed to
usbtest_alloc_urb(). Another way of dealing with this would be to
respect ARCH_KMALLOC_MINALIGN in hcd_buffer_create() and having the
smallest buffer starting at 64 bytes in this case.

Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
---
 drivers/usb/misc/usbtest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index 0bbafe795a72..bad57d6b9e7e 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -242,6 +242,8 @@ static struct urb *usbtest_alloc_urb(
 {
        struct urb              *urb;
 
+       if (offset > 1)
+               return NULL;
        urb = usb_alloc_urb(0, GFP_KERNEL);
        if (!urb)
                return urb;
@@ -324,7 +326,7 @@ static inline void simple_fill_buf(struct urb *urb)
 
 static inline unsigned long buffer_offset(void *buf)
 {
-       return (unsigned long)buf & (ARCH_KMALLOC_MINALIGN - 1);
+       return (unsigned long)buf & 1;
 }
 
 static int check_guard_bytes(struct usbtest_dev *tdev, struct urb *urb)
-- 
2.1.3

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to