ff74745e6d
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>
50 lines
1.1 KiB
C
50 lines
1.1 KiB
C
/*
|
|
* u_rndis.h
|
|
*
|
|
* Utility definitions for the subset function
|
|
*
|
|
* Copyright (c) 2013 Samsung Electronics Co., Ltd.
|
|
* http://www.samsung.com
|
|
*
|
|
* Author: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#ifndef U_RNDIS_H
|
|
#define U_RNDIS_H
|
|
|
|
#include <linux/usb/composite.h>
|
|
|
|
struct f_rndis_opts {
|
|
struct usb_function_instance func_inst;
|
|
u32 vendor_id;
|
|
const char *manufacturer;
|
|
struct net_device *net;
|
|
bool bound;
|
|
bool borrowed_net;
|
|
|
|
struct config_group *rndis_interf_group;
|
|
struct usb_os_desc rndis_os_desc;
|
|
char rndis_ext_compat_id[16];
|
|
|
|
u8 class;
|
|
u8 subclass;
|
|
u8 protocol;
|
|
|
|
/*
|
|
* Read/write access to configfs attributes is handled by configfs.
|
|
*
|
|
* This is to protect the data from concurrent access by read/write
|
|
* and create symlink/remove symlink.
|
|
*/
|
|
struct mutex lock;
|
|
int refcnt;
|
|
};
|
|
|
|
void rndis_borrow_net(struct usb_function_instance *f, struct net_device *net);
|
|
|
|
#endif /* U_RNDIS_H */
|