aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget
diff options
context:
space:
mode:
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>2012-03-28 03:30:50 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-04-27 12:51:08 -0400
commit2ac8fc00b350ba1aead453c9c1feb1d23a433321 (patch)
tree7505fd1878f5cbfe47d4808185edccbcc80b1a6b /drivers/usb/gadget
parent5eb68e665cadf165741a04c695a71cff11e1d4f1 (diff)
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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r--drivers/usb/gadget/f_fs.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/usb/gadget/f_fs.c b/drivers/usb/gadget/f_fs.c
index 19fffccc370..1cefb9f1607 100644
--- a/drivers/usb/gadget/f_fs.c
+++ b/drivers/usb/gadget/f_fs.c
@@ -720,7 +720,7 @@ static long ffs_ep0_ioctl(struct file *file, unsigned code, unsigned long value)
720 if (code == FUNCTIONFS_INTERFACE_REVMAP) { 720 if (code == FUNCTIONFS_INTERFACE_REVMAP) {
721 struct ffs_function *func = ffs->func; 721 struct ffs_function *func = ffs->func;
722 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV; 722 ret = func ? ffs_func_revmap_intf(func, value) : -ENODEV;
723 } else if (gadget->ops->ioctl) { 723 } else if (gadget && gadget->ops->ioctl) {
724 ret = gadget->ops->ioctl(gadget, code, value); 724 ret = gadget->ops->ioctl(gadget, code, value);
725 } else { 725 } else {
726 ret = -ENOTTY; 726 ret = -ENOTTY;