diff options
author | Marek Szyprowski <m.szyprowski@samsung.com> | 2011-01-28 07:55:36 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-02-04 14:57:22 -0500 |
commit | ce1fd3585709e833ad102167024e97217734dbfd (patch) | |
tree | 4d87314cc66c9631ae0cae5e7d48c84dee5b07b3 /drivers/usb/gadget | |
parent | 9a1b2e64020d41c577881952734fecd114af75f1 (diff) |
USB: gadget: f_fs: even zero-length packets require a buffer
Some UDC drivers fails to queue a request if req->buf == NULL even for
ZLP requests. This patch adds a poisoned pointer instead of NULL to
make the code compliant with the gadget specification and catches
possible bug in the UDC driver if it tries to dereference buffer pointer
on ZLP request.
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/f_fs.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c index 1499f9e4afa8..19fffccc370d 100644 --- a/drivers/usb/gadget/f_fs.c +++ b/drivers/usb/gadget/f_fs.c | |||
@@ -368,6 +368,14 @@ static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len) | |||
368 | req->buf = data; | 368 | req->buf = data; |
369 | req->length = len; | 369 | req->length = len; |
370 | 370 | ||
371 | /* | ||
372 | * UDC layer requires to provide a buffer even for ZLP, but should | ||
373 | * not use it at all. Let's provide some poisoned pointer to catch | ||
374 | * possible bug in the driver. | ||
375 | */ | ||
376 | if (req->buf == NULL) | ||
377 | req->buf = (void *)0xDEADBABE; | ||
378 | |||
371 | INIT_COMPLETION(ffs->ep0req_completion); | 379 | INIT_COMPLETION(ffs->ep0req_completion); |
372 | 380 | ||
373 | ret = usb_ep_queue(ffs->gadget->ep0, req, GFP_ATOMIC); | 381 | ret = usb_ep_queue(ffs->gadget->ep0, req, GFP_ATOMIC); |