Fix possible null ptr dereference
@@ -420,16 +420,14 @@ void USB_WritePacket(const void *src, uint16_t len, uint32_t ep) {
USBx_INEP(ep)->DIEPCTL |= (USB_OTG_DIEPCTL_CNAK | USB_OTG_DIEPCTL_EPENA);
// load the FIFO
+ if (src != NULL) {
const uint32_t *src_copy = (const uint32_t *)src;
for (uint32_t i = 0; i < count32b; i++) {
- // FIXME:
- // cppcheck-suppress nullPointer
USBx_DFIFO(ep) = *src_copy;
- // FIXME:
- // cppcheck-suppress nullPointerArithmetic
src_copy++;
}
}
+}
// IN EP 0 TX FIFO has a max size of 127 bytes (much smaller than the rest)
// so use TX FIFO empty interrupt to send larger amounts of data
