@@ -1847,9 +1847,26 @@ static void free_event_context(struct vchiq_mmal_port *port)
1847
1847
{
1848
1848
struct mmal_msg_context * ctx = port -> event_context ;
1849
1849
1850
+ if (!ctx )
1851
+ return ;
1852
+
1850
1853
kfree (ctx -> u .bulk .buffer -> buffer );
1851
1854
kfree (ctx -> u .bulk .buffer );
1852
1855
release_msg_context (ctx );
1856
+ port -> event_context = NULL ;
1857
+ }
1858
+
1859
+ static void release_all_event_contexts (struct vchiq_mmal_component * component )
1860
+ {
1861
+ int idx ;
1862
+
1863
+ for (idx = 0 ; idx < component -> inputs ; idx ++ )
1864
+ free_event_context (& component -> input [idx ]);
1865
+ for (idx = 0 ; idx < component -> outputs ; idx ++ )
1866
+ free_event_context (& component -> output [idx ]);
1867
+ for (idx = 0 ; idx < component -> clocks ; idx ++ )
1868
+ free_event_context (& component -> clock [idx ]);
1869
+ free_event_context (& component -> control );
1853
1870
}
1854
1871
1855
1872
/* Initialise a mmal component and its ports
@@ -1947,6 +1964,7 @@ int vchiq_mmal_component_init(struct vchiq_mmal_instance *instance,
1947
1964
1948
1965
release_component :
1949
1966
destroy_component (instance , component );
1967
+ release_all_event_contexts (component );
1950
1968
unlock :
1951
1969
if (component )
1952
1970
component -> in_use = 0 ;
@@ -1962,7 +1980,7 @@ EXPORT_SYMBOL_GPL(vchiq_mmal_component_init);
1962
1980
int vchiq_mmal_component_finalise (struct vchiq_mmal_instance * instance ,
1963
1981
struct vchiq_mmal_component * component )
1964
1982
{
1965
- int ret , idx ;
1983
+ int ret ;
1966
1984
1967
1985
if (mutex_lock_interruptible (& instance -> vchiq_mutex ))
1968
1986
return - EINTR ;
@@ -1974,14 +1992,7 @@ int vchiq_mmal_component_finalise(struct vchiq_mmal_instance *instance,
1974
1992
1975
1993
component -> in_use = 0 ;
1976
1994
1977
- for (idx = 0 ; idx < component -> inputs ; idx ++ )
1978
- free_event_context (& component -> input [idx ]);
1979
- for (idx = 0 ; idx < component -> outputs ; idx ++ )
1980
- free_event_context (& component -> output [idx ]);
1981
- for (idx = 0 ; idx < component -> clocks ; idx ++ )
1982
- free_event_context (& component -> clock [idx ]);
1983
-
1984
- free_event_context (& component -> control );
1995
+ release_all_event_contexts (component );
1985
1996
1986
1997
mutex_unlock (& instance -> vchiq_mutex );
1987
1998
0 commit comments