]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usb: gadget: goku_udc: fix potential crashes in probe
authorEvgeny Novikov <novikov@ispras.ru>
Fri, 2 Oct 2020 15:01:55 +0000 (18:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Nov 2020 18:18:44 +0000 (19:18 +0100)
commit5cfb8377e8af998ea6bd092cce32510fbae29e9c
tree62359f6ec99c613e254562c4f3fe3baf52111a71
parentfe4d386d6c2a497ec0020164647497e23f10bfdd
usb: gadget: goku_udc: fix potential crashes in probe

[ Upstream commit 0d66e04875c5aae876cf3d4f4be7978fa2b00523 ]

goku_probe() goes to error label "err" and invokes goku_remove()
in case of failures of pci_enable_device(), pci_resource_start()
and ioremap(). goku_remove() gets a device from
pci_get_drvdata(pdev) and works with it without any checks, in
particular it dereferences a corresponding pointer. But
goku_probe() did not set this device yet. So, one can expect
various crashes. The patch moves setting the device just after
allocation of memory for it.

Found by Linux Driver Verification project (linuxtesting.org).

Reported-by: Pavel Andrianov <andrianov@ispras.ru>
Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/gadget/udc/goku_udc.c