Skip to content

Commit

Permalink
USB: gadget: f_fs: even zero-length packets require a buffer
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Marek Szyprowski authored and Greg Kroah-Hartman committed Feb 4, 2011
1 parent 9a1b2e6 commit ce1fd35
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/usb/gadget/f_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,14 @@ static int __ffs_ep0_queue_wait(struct ffs_data *ffs, char *data, size_t len)
req->buf = data;
req->length = len;

/*
* UDC layer requires to provide a buffer even for ZLP, but should
* not use it at all. Let's provide some poisoned pointer to catch
* possible bug in the driver.
*/
if (req->buf == NULL)
req->buf = (void *)0xDEADBABE;

INIT_COMPLETION(ffs->ep0req_completion);

ret = usb_ep_queue(ffs->gadget->ep0, req, GFP_ATOMIC);
Expand Down

0 comments on commit ce1fd35

Please sign in to comment.