usb: musb: sunxi: Fix NULL ptr deref when gadget is registered before musb
authorHans de Goede <hdegoede@redhat.com>
Tue, 14 Jun 2016 20:13:05 +0000 (15:13 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jun 2016 20:36:23 +0000 (13:36 -0700)
commit969a132723434f3723cc0606373785d19c1d2f05
treec3ba8c523258e8ef758744e0e7e4a6ddb102f7da
parente4600d56323ed119469fdcb21564f7544e1e6b3c
usb: musb: sunxi: Fix NULL ptr deref when gadget is registered before musb

Stop using the return value of platform_device_register_full() to get to
the struct musb in sunxi_musb_work(). If a gadget has been registered
(insmod-ed) before the musb driver, then musb_start will get called
from the musb_core probe function and sunxi_musb_work() may run before
platform_device_register_full() has returned.

Instead store a pointer to struct musb in struct sunxi_glue when
sunxi_musb_enable gets called. Note that sunxi_musb_enable always gets
called before sunxi_musb_work() can run.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
[b-liu@ti.com: revise subject prefix]
Signed-off-by: Bin Liu <b-liu@ti.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/musb/sunxi.c