OpenCloudOS-Kernel/drivers/usb/gadget/function
Andrew Gabbasov ff74745e6d usb: gadget: configfs: Fix memory leak of interface directory data
Kmemleak checking configuration reports a memory leak in
usb_os_desc_prepare_interf_dir function when rndis function
instance is freed and then allocated again. For example, this
happens with FunctionFS driver with RNDIS function enabled
when "ffs-test" test application is run several times in a row.

The data for intermediate "os_desc" group for interface directories
is allocated as a single VLA chunk and (after a change of default
groups handling) is not ever freed and actually not stored anywhere
besides inside a list of default groups of a parent group.

The fix is to make usb_os_desc_prepare_interf_dir function return
a pointer to allocated data (as a pointer to the first VLA item)
instead of (an unused) integer and to make the caller component
(currently the only one is RNDIS function) responsible for storing
the pointer and freeing the memory when appropriate.

Fixes: 1ae1602de0 ("configfs: switch ->default groups to a linked list")
Cc: stable@vger.kernel.org
Signed-off-by: Andrew Gabbasov <andrew_gabbasov@mentor.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
2017-10-11 13:14:37 +03:00
..
Makefile usb: gadget: add f_uac1 variant based on a new u_audio api 2017-06-19 09:22:47 +03:00
f_acm.c usb: gadget: acm: fix endianness in notifications 2017-03-22 11:20:52 +02:00
f_ecm.c usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus 2016-03-04 15:14:23 +02:00
f_eem.c usb: gadget: prevent potenial null pointer dereference on skb->len 2016-09-06 10:44:03 +03:00
f_fs.c usb: gadget: ffs: handle I/O completion in-order 2017-09-28 12:37:24 +03:00
f_hid.c usb: gadget: f_hid: {GET,SET} PROTOCOL Support 2017-08-15 12:46:03 +03:00
f_loopback.c usb: gadget: remove variable ret and remove unnecessary if statement 2016-09-09 13:38:37 +03:00
f_mass_storage.c USB: g_mass_storage: Fix deadlock when driver is unbound 2017-09-22 18:29:00 +02:00
f_mass_storage.h USB: g_mass_storage: Fix deadlock when driver is unbound 2017-09-22 18:29:00 +02:00
f_midi.c usb: gadget: f_midi: Use snd_card_free_when_closed with refcount 2017-08-15 14:18:47 +03:00
f_ncm.c usb: gadget: f_ncm/u_ether: Move 'SKB reserve' quirk setup to u_ether 2017-08-18 12:29:10 +03:00
f_obex.c usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus 2016-03-04 15:14:23 +02:00
f_phonet.c networking: introduce and use skb_put_data() 2017-06-16 11:48:37 -04:00
f_printer.c usb: gadget: function: printer: avoid spinlock recursion 2017-09-20 14:57:28 +03:00
f_rndis.c usb: gadget: configfs: Fix memory leak of interface directory data 2017-10-11 13:14:37 +03:00
f_serial.c usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus 2016-03-04 15:14:23 +02:00
f_sourcesink.c usb: gadget: remove useless parameter in alloc_ep_req() 2016-08-25 12:13:19 +03:00
f_subset.c usb: gadget: Update usb_assign_descriptors for SuperSpeedPlus 2016-03-04 15:14:23 +02:00
f_tcm.c usb: gadget: Correct usb EP argument for BOT status request 2017-03-30 01:36:50 -07:00
f_uac1.c usb: gadget: f_uac1: endianness fixes. 2017-07-18 09:33:16 +03:00
f_uac1_legacy.c usb: gadget: function: make current f_uac1 implementation legacy 2017-06-19 09:22:47 +03:00
f_uac2.c usb: gadget: f_uac2: endianness fixes. 2017-07-18 09:33:19 +03:00
f_uvc.c usb: gadget: f_uvc: Sanity check wMaxPacketSize for SuperSpeed 2017-03-22 11:21:09 +02:00
f_uvc.h
g_zero.h usb: gadget: define free_ep_req as universal function 2015-12-15 09:12:41 -06:00
ndis.h
rndis.c networking: make skb_push & __skb_push return void pointers 2017-06-16 11:48:40 -04:00
rndis.h usb: gadget: Fix checkpatch error for braces 2016-11-18 13:54:41 +02:00
storage_common.c usb: gadget: Add per-lun inquiry string 2016-08-25 12:13:13 +03:00
storage_common.h USB: f_mass_storage: improve memory barriers and synchronization 2017-05-16 10:38:33 +03:00
tcm.h usb-gadget/tcm: Conversion to percpu_ida tag pre-allocation 2016-03-10 21:48:14 -08:00
u_audio.c usb: gadget: make snd_pcm_hardware const 2017-08-28 11:39:33 +02:00
u_audio.h usb: gadget: f_uac2: split out audio core 2017-06-19 09:22:46 +03:00
u_ecm.h
u_eem.h
u_ether.c usb: gadget: f_ncm/u_ether: Move 'SKB reserve' quirk setup to u_ether 2017-08-18 12:29:10 +03:00
u_ether.h usb: gadget: f_ncm/u_ether: Move 'SKB reserve' quirk setup to u_ether 2017-08-18 12:29:10 +03:00
u_ether_configfs.h usb: gadget: add RNDIS configfs options for class/subclass/protocol 2017-08-15 14:18:56 +03:00
u_fs.h usb: gadget: ffs: handle I/O completion in-order 2017-09-28 12:37:24 +03:00
u_gether.h
u_hid.h
u_midi.h
u_ncm.h
u_phonet.h
u_printer.h usb: gadget: printer: Remove pnp_string static buffer 2017-01-24 11:04:08 +02:00
u_rndis.h usb: gadget: configfs: Fix memory leak of interface directory data 2017-10-11 13:14:37 +03:00
u_serial.c usb: gadget: serial: fix oops when data rx'd after close 2017-08-18 12:28:50 +03:00
u_serial.h
u_tcm.h usb: gadget: f_tcm: convert to new function interface with backward compatibility 2015-12-20 19:40:34 -08:00
u_uac1.h usb: gadget: add f_uac1 variant based on a new u_audio api 2017-06-19 09:22:47 +03:00
u_uac1_legacy.c sound updates for 4.13-rc1 2017-07-06 10:56:51 -07:00
u_uac1_legacy.h usb: gadget: function: make current f_uac1 implementation legacy 2017-06-19 09:22:47 +03:00
u_uac2.h usb: gadget: uac2: add req_number as parameter 2017-01-24 11:04:21 +02:00
u_uvc.h
uvc.h usb: gadget: Fix checkpatch error for braces 2016-11-18 13:54:41 +02:00
uvc_configfs.c usb: gadget: uvc: Missing files for configfs interface 2017-04-11 10:57:59 +03:00
uvc_configfs.h
uvc_queue.c [media] vb2: replace void *alloc_ctxs by struct device *alloc_devs 2016-07-08 14:45:07 -03:00
uvc_queue.h
uvc_v4l2.c usb: gadget: Fix checkpatch error for braces 2016-11-18 13:54:41 +02:00
uvc_v4l2.h
uvc_video.c usb: gadget: composite: always set ep->mult to a sensible value 2016-10-31 11:15:33 +02:00
uvc_video.h