]> git.baikalelectronics.ru Git - kernel.git/commit
usb: gadget: fix NULL pointer dereference
authorAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Mon, 20 Jan 2014 07:33:50 +0000 (08:33 +0100)
committerFelipe Balbi <balbi@ti.com>
Thu, 20 Feb 2014 15:17:23 +0000 (09:17 -0600)
commit12ac3a3b5141bca5338342a03b967a7549fbd4cb
tree5e564e3f582d872a91433cc62dc1fa3ff8007cbd
parent287fb8b7566d2b81872dcffdff73c186a6b866e2
usb: gadget: fix NULL pointer dereference

Fix possible NULL pointer dereference introduced in
commit ef97f97 (usb: f_fs: check quirk to pad epout
buf size when not aligned to maxpacketsize)

In cases we do wait with:

wait_event_interruptible(epfile->wait, (ep = epfile->ep));

for endpoint to be enabled, functionfs_bind() has not been called yet
and epfile->ffs->gadget is still NULL and the automatic variable 'gadget'
has been initialized with NULL at the point of its definition.
Later on it is used as a parameter to:

usb_ep_align_maybe(gadget, ep->ep, len)

which in turn dereferences it.

This patch fixes it by moving the actual assignment to the local 'gadget'
variable after the potential waiting has completed.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/gadget/f_fs.c