From a1fda4f2182b99404cef8dca44e388d3482b2f69 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Wed, 26 Apr 2017 09:18:26 +0200 Subject: [PATCH] Fixed a possible crash when pulling the CAM while decrypting a channel with MTD (cont'd) --- ci.c | 7 +++++-- mtd.c | 8 +++++++- mtd.h | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/ci.c b/ci.c index ee338279..f64c17e3 100644 --- a/ci.c +++ b/ci.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: ci.c 4.12 2017/04/24 09:05:49 kls Exp $ + * $Id: ci.c 4.13 2017/04/26 09:18:26 kls Exp $ */ #include "ci.h" @@ -1971,7 +1971,10 @@ void cCamSlot::Process(cTPDU *TPDU) StopDecrypting(); DeleteAllConnections(); CancelActivation(); - MtdActivate(false); + if (mtdHandler) + mtdHandler->UnAssignAll(); + else + Assign(NULL); break; case msReset: dbgprotocol("Slot %d: module reset\n", slotNumber); diff --git a/mtd.c b/mtd.c index bf792dd9..29fe520f 100644 --- a/mtd.c +++ b/mtd.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: mtd.c 1.9 2017/03/27 14:26:04 kls Exp $ + * $Id: mtd.c 1.10 2017/04/26 08:33:54 kls Exp $ */ #include "mtd.h" @@ -136,6 +136,12 @@ bool cMtdHandler::Devices(cVector &CardIndexes) return CardIndexes.Size() > 0; } +void cMtdHandler::UnAssignAll(void) +{ + for (int i = 0; i < camSlots.Size(); i++) + camSlots[i]->Assign(NULL); +} + // --- cMtdMapper ------------------------------------------------------------ #define MTD_INVALID_PID 0xFFFF diff --git a/mtd.h b/mtd.h index b7742022..7f2151a3 100644 --- a/mtd.h +++ b/mtd.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: mtd.h 1.6 2017/03/27 08:30:00 kls Exp $ + * $Id: mtd.h 1.7 2017/04/26 09:17:08 kls Exp $ */ #ifndef __MTD_H @@ -140,6 +140,8 @@ public: ///< Adds the card indexes of the devices of any active MTD CAM slots to ///< the given CardIndexes. ///< Returns true if the array is not empty. + void UnAssignAll(void); + ///< Unassigns all MTD CAM slots from their devices. }; #define MTD_DONT_CALL(v) dsyslog("PROGRAMMING ERROR (%s,%d): DON'T CALL %s", __FILE__, __LINE__, __FUNCTION__); return v;