usb/gadget: free opts struct on error recovery
Fix memory leaks introduced in commits:40d133d7f5
usb: gadget: f_ncm: convert to new function interface with backward compatibilityfee562a645
usb: gadget: f_ecm: convert to new function interface with backward compatibilityfcbdf12ebe
usb: gadget: f_phonet: convert to new function interface with backward compatibilityb29002a157
usb: gadget: f_eem: convert to new function interface with backward compatibility8cedba7c73
usb: gadget: f_subset: convert to new function interface with backward compatibilityf466c63538
usb: gadget: f_rndis: convert to new function interface with backward compatibility Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
5f8a2e68b6
commit
172d934c92
@@ -959,8 +959,11 @@ static struct usb_function_instance *ecm_alloc_inst(void)
|
|||||||
mutex_init(&opts->lock);
|
mutex_init(&opts->lock);
|
||||||
opts->func_inst.free_func_inst = ecm_free_inst;
|
opts->func_inst.free_func_inst = ecm_free_inst;
|
||||||
opts->net = gether_setup_default();
|
opts->net = gether_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_PTR(PTR_ERR(opts->net));
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
|
config_group_init_type_name(&opts->func_inst.group, "", &ecm_func_type);
|
||||||
|
|
||||||
|
@@ -593,8 +593,11 @@ static struct usb_function_instance *eem_alloc_inst(void)
|
|||||||
mutex_init(&opts->lock);
|
mutex_init(&opts->lock);
|
||||||
opts->func_inst.free_func_inst = eem_free_inst;
|
opts->func_inst.free_func_inst = eem_free_inst;
|
||||||
opts->net = gether_setup_default();
|
opts->net = gether_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_CAST(opts->net);
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
|
config_group_init_type_name(&opts->func_inst.group, "", &eem_func_type);
|
||||||
|
|
||||||
|
@@ -1350,8 +1350,11 @@ static struct usb_function_instance *ncm_alloc_inst(void)
|
|||||||
mutex_init(&opts->lock);
|
mutex_init(&opts->lock);
|
||||||
opts->func_inst.free_func_inst = ncm_free_inst;
|
opts->func_inst.free_func_inst = ncm_free_inst;
|
||||||
opts->net = gether_setup_default();
|
opts->net = gether_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_PTR(PTR_ERR(opts->net));
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "", &ncm_func_type);
|
config_group_init_type_name(&opts->func_inst.group, "", &ncm_func_type);
|
||||||
|
|
||||||
|
@@ -656,8 +656,11 @@ static struct usb_function_instance *phonet_alloc_inst(void)
|
|||||||
|
|
||||||
opts->func_inst.free_func_inst = phonet_free_inst;
|
opts->func_inst.free_func_inst = phonet_free_inst;
|
||||||
opts->net = gphonet_setup_default();
|
opts->net = gphonet_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_PTR(PTR_ERR(opts->net));
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "",
|
config_group_init_type_name(&opts->func_inst.group, "",
|
||||||
&phonet_func_type);
|
&phonet_func_type);
|
||||||
|
@@ -963,8 +963,11 @@ static struct usb_function_instance *rndis_alloc_inst(void)
|
|||||||
mutex_init(&opts->lock);
|
mutex_init(&opts->lock);
|
||||||
opts->func_inst.free_func_inst = rndis_free_inst;
|
opts->func_inst.free_func_inst = rndis_free_inst;
|
||||||
opts->net = gether_setup_default();
|
opts->net = gether_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_CAST(opts->net);
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "",
|
config_group_init_type_name(&opts->func_inst.group, "",
|
||||||
&rndis_func_type);
|
&rndis_func_type);
|
||||||
|
@@ -505,8 +505,11 @@ static struct usb_function_instance *geth_alloc_inst(void)
|
|||||||
mutex_init(&opts->lock);
|
mutex_init(&opts->lock);
|
||||||
opts->func_inst.free_func_inst = geth_free_inst;
|
opts->func_inst.free_func_inst = geth_free_inst;
|
||||||
opts->net = gether_setup_default();
|
opts->net = gether_setup_default();
|
||||||
if (IS_ERR(opts->net))
|
if (IS_ERR(opts->net)) {
|
||||||
return ERR_CAST(opts->net);
|
struct net_device *net = opts->net;
|
||||||
|
kfree(opts);
|
||||||
|
return ERR_CAST(net);
|
||||||
|
}
|
||||||
|
|
||||||
config_group_init_type_name(&opts->func_inst.group, "",
|
config_group_init_type_name(&opts->func_inst.group, "",
|
||||||
&gether_func_type);
|
&gether_func_type);
|
||||||
|
Reference in New Issue
Block a user