usb: gadget: eliminate NULL pointer dereference (bugfix)
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Wed, 28 Mar 2012 07:30:50 +0000 (09:30 +0200)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 May 2012 12:14:05 +0000 (13:14 +0100)
commit5292bdd3ee31c6893a62df34b39e3814bfa4b553
tree66ef6ae2458929a7859485574a1448968fe3353a
parent2eefeef94ff4472fb873c5803122358ba43a66db
usb: gadget: eliminate NULL pointer dereference (bugfix)

commit 92b0abf80c5c5f0e0d71d1309688a330fd74731b upstream.

usb: gadget: eliminate NULL pointer dereference (bugfix)

This patch fixes a bug which causes NULL pointer dereference in
ffs_ep0_ioctl. The bug happens when the FunctionFS is not bound (either
has not been bound yet or has been bound and then unbound) and can be
reproduced with running the following commands:

$ insmod g_ffs.ko
$ mount -t functionfs func /dev/usbgadget
$ ./null

where null.c is:

#include <fcntl.h>
#include <linux/usb/functionfs.h>

int main(void)
{
int fd = open("/dev/usbgadget/ep0", O_RDWR);
ioctl(fd, FUNCTIONFS_CLEAR_HALT);

return 0;
}

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/usb/gadget/f_fs.c