Skip to contentSkip to conversation

usb: gadget: storage: Fix reference count if fsg_alloc_inst() failed

PATCH New Jaejoong Kim 1 participant 1 message Jun 14, 2018 USB

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 usb: gadget: storage: Fix reference count if fsg_alloc_inst() failed

The reference count is initialized in fsg_alloc_inst(). So if fsg_alloc_inst() fails, we need to add kref_put() to free an allocated memory.

---
 drivers/usb/gadget/function/f_mass_storage.c | 1 +
 1 file changed, 1 insertion(+)
drivers/usb/gadget/function/f_mass_storage.c +1 -0
index acecd13..83eeafe 100644
@@ -3392,6 +3392,7 @@ static struct usb_function_instance *fsg_alloc_inst(void)
 release_buffers:
 	fsg_common_free_buffers(opts->common);
 release_opts:
+	fsg_common_put(opts->common);
 	kfree(opts);
 	return ERR_PTR(rc);
 }