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)
committerFelipe Balbi <balbi@kernel.org>
Tue, 27 Oct 2020 08:55:45 +0000 (10:55 +0200)
commit0d66e04875c5aae876cf3d4f4be7978fa2b00523
tree7b14d2c0967c1b34359efc24d85bfd072094e21c
parent1384ab4fee12c4c4f8bd37bc9f8686881587b286
usb: gadget: goku_udc: fix potential crashes in probe

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>
drivers/usb/gadget/udc/goku_udc.c