Skip to content

Commit

Permalink
Check for payload != NULL in smartPortPayloadContainsMSP()
Browse files Browse the repository at this point in the history
When calling it from the fport driver, the payload might be NULL in
some cases, causing an invalid dereference.

Found by @jirif on betaflight/betaflight#6060
  • Loading branch information
fiam committed Jun 8, 2018
1 parent 06d2beb commit df5d50d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/main/telemetry/smartport.c
Expand Up @@ -233,7 +233,7 @@ void smartPortSendByte(uint8_t c, uint16_t *checksum, serialPort_t *port)

bool smartPortPayloadContainsMSP(const smartPortPayload_t *payload)
{
return payload->frameId == FSSP_MSPC_FRAME_SMARTPORT || payload->frameId == FSSP_MSPC_FRAME_FPORT;
return payload && (payload->frameId == FSSP_MSPC_FRAME_SMARTPORT || payload->frameId == FSSP_MSPC_FRAME_FPORT);
}

void smartPortWriteFrameSerial(const smartPortPayload_t *payload, serialPort_t *port, uint16_t checksum)
Expand Down

0 comments on commit df5d50d

Please sign in to comment.