From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Driver Development Kit (DDK)

cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in SGLChunklyLink could cause crash if DMA allocation fails

While running a static analysis tool, I came across a bug, which if  hit, would cause a CRASH.

 

In the constructor tCHInChSGLChunkyLink::tCHInChSGLChunkyLink,

 

      _linkMemory = _bus->allocDMA(_maxSize);
      if (_linkMemory == NULL)
      {
         status.setCode(kBufferBadMemoryAllocation);
      }

      // Enforce 8-byte alignment for link memory addresses
      if (_linkMemory->getPhysicalAddress() % 8 != 0)
      {
         status.setCode(kBufferBadAlignment);
      }

 

If the memory could not be allocated, then _linkMemory is dereferenced.

The fix should move the derference inside a  "if (status.isNotFatal )"   check

0 Kudos
Message 1 of 2
(6,381 Views)

Hello Kenstern,

 

I appreciate you letting us know about your findings. I've recorded this in a bug report and we will be investigating the potential issue.

 

Thanks,

Steven T.

0 Kudos
Message 2 of 2
(6,372 Views)