drivers: CAN: Limit the DLC to 8
This commit limits the data length code to eight. DLC > 8 returns a newly introduced CAN_TX_EINVAL error code. Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
parent
4fc6a04eb1
commit
d558fd055a
6 changed files with 40 additions and 2 deletions
|
@ -548,7 +548,11 @@ int can_stm32_send(struct device *dev, const struct zcan_frame *msg,
|
|||
, msg->rtr == CAN_DATAFRAME ? "no" : "yes");
|
||||
|
||||
__ASSERT(msg->dlc == 0U || msg->data != NULL, "Dataptr is null");
|
||||
__ASSERT(msg->dlc <= CAN_MAX_DLC, "DLC > 8");
|
||||
|
||||
if (msg->dlc > CAN_MAX_DLC) {
|
||||
LOG_ERR("DLC of %d exceeds maximum (%d)", msg->dlc, CAN_MAX_DLC);
|
||||
return CAN_TX_EINVAL;
|
||||
}
|
||||
|
||||
if (can->ESR & CAN_ESR_BOFF) {
|
||||
return CAN_TX_BUS_OFF;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue