dahdi: Protect echocan creation/destruction with mutex.
This closes a reference and memory leak when multiple CPUs are enabling echocan on a single channel in parallel. The essential problem is that the call to try_module_get() is not serialized. Two separate threads can come into ioctl_echocan() on the same channel, they coordinate via the dahdi_chan.lock to release any current echocan, but then both create a new echocan state, bump the reference on the module, and the last one through will actually attach the new state to the channel. The earlier reference / memory is leaked. I tried to conceive of a way to fix this leak without adding a new lock, but the choices where calling throught the function pointers with dahdi_chan.lock. Otherwise I needed to change the semantics of echocan_create /free which would ripple through the hardware echocan modules. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
This commit is contained in:
committed by
Russ Meyerriecks
parent
cb50ae1500
commit
761e02da52
@@ -425,6 +425,7 @@ struct dahdi_chan {
|
||||
int lastnumbufs;
|
||||
#endif
|
||||
spinlock_t lock;
|
||||
struct mutex mutex;
|
||||
char name[40];
|
||||
/* Specified by DAHDI */
|
||||
/*! \brief DAHDI channel number */
|
||||
|
||||
Reference in New Issue
Block a user