mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module: handle type register errors
Registering an export type can give an error when the type is already registered. Handle those errors and refuse to load the module. See #2281
This commit is contained in:
		
							parent
							
								
									37fa911a72
								
							
						
					
					
						commit
						b97327e1f6
					
				
					 7 changed files with 50 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -163,6 +163,7 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
			
		|||
	struct pw_context *context = pw_impl_module_get_context(module);
 | 
			
		||||
	struct pw_impl_factory *factory;
 | 
			
		||||
	struct factory_data *data;
 | 
			
		||||
	int res;
 | 
			
		||||
 | 
			
		||||
	PW_LOG_TOPIC_INIT(mod_topic);
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -185,20 +186,27 @@ int pipewire__module_init(struct pw_impl_module *module, const char *args)
 | 
			
		|||
				      &impl_factory,
 | 
			
		||||
				      data);
 | 
			
		||||
 | 
			
		||||
	pw_protocol_native_ext_client_node_init(context);
 | 
			
		||||
	pw_protocol_native_ext_client_node0_init(context);
 | 
			
		||||
 | 
			
		||||
	data->export_node.type = PW_TYPE_INTERFACE_Node;
 | 
			
		||||
	data->export_node.func = pw_core_node_export;
 | 
			
		||||
	pw_context_register_export_type(context, &data->export_node);
 | 
			
		||||
	if ((res = pw_context_register_export_type(context, &data->export_node)) < 0)
 | 
			
		||||
		goto error;
 | 
			
		||||
 | 
			
		||||
	data->export_spanode.type = SPA_TYPE_INTERFACE_Node;
 | 
			
		||||
	data->export_spanode.func = pw_core_spa_node_export;
 | 
			
		||||
	pw_context_register_export_type(context, &data->export_spanode);
 | 
			
		||||
	if ((res = pw_context_register_export_type(context, &data->export_spanode)) < 0)
 | 
			
		||||
		goto error_remove;
 | 
			
		||||
 | 
			
		||||
	pw_protocol_native_ext_client_node_init(context);
 | 
			
		||||
	pw_protocol_native_ext_client_node0_init(context);
 | 
			
		||||
 | 
			
		||||
	pw_impl_module_add_listener(module, &data->module_listener, &module_events, data);
 | 
			
		||||
 | 
			
		||||
	pw_impl_module_update_properties(module, &SPA_DICT_INIT_ARRAY(module_props));
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
error_remove:
 | 
			
		||||
	spa_list_remove(&data->export_node.link);
 | 
			
		||||
error:
 | 
			
		||||
	pw_impl_factory_destroy(data->this);
 | 
			
		||||
	return res;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue