• A
    usb: gadget: configfs: Fix memory leak of interface directory data · ff74745e
    Andrew Gabbasov 提交于
    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: 1ae1602d ("configfs: switch ->default groups to a linked list")
    Cc: stable@vger.kernel.org
    Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
    Signed-off-by: NFelipe Balbi <felipe.balbi@linux.intel.com>
    ff74745e
configfs.c 37.0 KB