usb: gadget: Fix null pointer crash issue in gsi_free_inst

If misc register failed then there is a chance for accessing the
null pointer in gsi_free_inst function and leads to target crash.
Hence add the change to handle the same.

Change-Id: Iaa3f7db1403ca2d87f259dec109912c5437c24f4
Signed-off-by: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
This commit is contained in:
Chandana Kishori Chiluveru 2016-12-30 17:26:09 +05:30
parent e51c3cc83f
commit 99392dcd7d

View file

@ -3007,6 +3007,9 @@ static void gsi_free_inst(struct usb_function_instance *f)
{
struct gsi_opts *opts = container_of(f, struct gsi_opts, func_inst);
if (!opts->gsi)
return;
if (opts->gsi->c_port.ctrl_device.fops)
misc_deregister(&opts->gsi->c_port.ctrl_device);