usb: cdns3: gadget: fix possible memory leak
authorPeter Chen <peter.chen@nxp.com>
Fri, 21 Aug 2020 02:55:47 +0000 (10:55 +0800)
committerFelipe Balbi <balbi@kernel.org>
Fri, 2 Oct 2020 06:57:42 +0000 (09:57 +0300)
commit6b7778924c70dad395f6aa843d641e799590f890
treed25fcc1fce26d163a1c98a2c67df2c211f1279ac
parent9b719c7119e77e8ddeefe4772c554d2863579c2b
usb: cdns3: gadget: fix possible memory leak

If cdns3_gadget_start is failed, it never frees cdns3_device structure.
Meanwhile, there is no release function for gadget device, it causes
there is no sync with driver core.

To fix this, we add release function for gadget device, and free
cdns3_device structure at there. Meanwhile, With the new UDC core
APIs, we could work with driver core better to handle memory leak
issue.

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
drivers/usb/cdns3/gadget.c