lkml.org 
[lkml]   [2009]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[patch] USB: serial: fix DMA buffers on stack for io_edgeport.c
The original code did DMA on a stack variable, so I made it an allocated 
pointer.

Compile tested only.

Signed-off-by: Dan Carpenter <error27@gmail.com>

--- orig/drivers/usb/serial/io_edgeport.c 2009-12-30 16:20:35.000000000 +0200
+++ devel/drivers/usb/serial/io_edgeport.c 2009-12-30 16:25:27.000000000 +0200
@@ -372,21 +372,24 @@ static void update_edgeport_E2PROM(struc
************************************************************************/
static int get_string(struct usb_device *dev, int Id, char *string, int buflen)
{
- struct usb_string_descriptor StringDesc;
+ struct usb_string_descriptor *StringDesc;
struct usb_string_descriptor *pStringDesc;

dbg("%s - USB String ID = %d", __func__, Id);

+ StringDesc = kmalloc(sizeof(*StringDesc), GFP_KERNEL);
+ if (!StringDesc)
+ return 0;
if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
- &StringDesc, sizeof(StringDesc)))
+ StringDesc, sizeof(*StringDesc)))
return 0;

- pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
+ pStringDesc = kmalloc(StringDesc->bLength, GFP_KERNEL);
if (!pStringDesc)
return 0;

if (!usb_get_descriptor(dev, USB_DT_STRING, Id,
- pStringDesc, StringDesc.bLength)) {
+ pStringDesc, StringDesc->bLength)) {
kfree(pStringDesc);
return 0;
}

\
 
 \ /
  Last update: 2009-12-30 17:09    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site