Hilscher Gesellschaft für Systemautomation mbH
There is a little error inside the cifX Toolkit in Interrupt mode, which will result in a NULL pointer access if a cifX device has a system channel only (no FW loaded). This bug only occurs in interrupt mode.
The following change fixes this problem:
Index: cifXInterrupt.c
===================================================================
--- cifXInterrupt.c (revision 1496)
+++ cifXInterrupt.c (revision 1497)
@@ -325,13 +325,15 @@
for(ulBitPos = 0; ulBitPos < NETX_NUM_OF_SYNCH_FLAGS; ++ulBitPos)
{
/* There is a valid channel */
- uint16_t usBitMask = (uint16_t)(1 << ulBitPos);
- uint8_t bState = RCX_FLAGS_NOT_EQUAL;
-
- PCHANNELINSTANCE ptChannel = (PCHANNELINSTANCE)ptDevInstance->pptCommChannels[ulBitPos];
+ uint16_t usBitMask = (uint16_t)(1 << ulBitPos);
+ uint8_t bState = RCX_FLAGS_NOT_EQUAL;
+ PCHANNELINSTANCE ptChannel = NULL;
+
if (ulBitPos >= ptDevInstance->ulCommChannelCount)
break;
+ ptChannel = (PCHANNELINSTANCE)ptDevInstance->pptCommChannels[ulBitPos];
+
/* Handle Sync interrupts */
if( RCX_SYNC_MODE_HST_CTRL == ptChannel->ptCommonStatusBlock->bSyncHskMode)
bState = RCX_FLAGS_EQUAL;
Note: For those that cannot read diff-files. You need to exchange the lines 331 and 332-333. The "if"-statement must be before the assignment of ptChannel = (PCHANNELINSTANCE)ptDevInstance->pptCommChannels[ulBitPos];