From 2b9bcff79a02f770fa730e2689ba35cc03c0da7d Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 20 Jan 2017 10:03:45 +0100 Subject: usb: gadget: properly release f_multi_opts The usbgadget commands uses statically allocated f_multi_opts and passes this to usb_multi_register(). These f_multi_opts are of course no longer valid when we leave the usbgadget command. Luckily we do not use the data after we left the usbgadget command, so this never has been a problem. However, f_multi_opts has some allocated members which we can not free anymore on gadget unregistration because we no longer have the pointer to them. Fix this by adding a release function to struct f_multi_opts. This way we can allocate all memory dynamically and properly free it when not used anymore. Signed-off-by: Sascha Hauer --- include/usb/gadget-multi.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include/usb') diff --git a/include/usb/gadget-multi.h b/include/usb/gadget-multi.h index 5ca462326a..81beddc7cf 100644 --- a/include/usb/gadget-multi.h +++ b/include/usb/gadget-multi.h @@ -9,9 +9,11 @@ struct f_multi_opts { struct f_fastboot_opts fastboot_opts; struct f_dfu_opts dfu_opts; int create_acm; + void (*release)(struct f_multi_opts *opts); }; int usb_multi_register(struct f_multi_opts *opts); void usb_multi_unregister(void); +void usb_multi_opts_release(struct f_multi_opts *opts); #endif /* __USB_GADGET_MULTI_H */ -- cgit v1.2.3