drivers: can: stm32_can: Fix shifting zero width or out of bounds

When attaching the filters in a way that the filter width dos not change
but the type, CAN_NO_FREE_FILTER was returned when the new filter is at
the end. Also shifting is not necessary when the start is already out
of bounds.

Signed-off-by: Alexander Wachter <alexander.wachter@student.tugraz.at>
This commit is contained in:
Alexander Wachter 2019-02-13 11:18:27 +01:00 committed by Anas Nashif
commit 8484855428

View file

@ -702,6 +702,8 @@ static inline int can_stm32_set_filter(const struct zcan_filter *filter,
scale_reg);
start_index = filter_index_new + filter_in_bank[bank_mode];
if (shift_width && start_index <= CAN_MAX_NUMBER_OF_FILTERS) {
res = can_stm32_shift_arr(device_data->rx_response,
start_index,
shift_width);
@ -715,6 +717,8 @@ static inline int can_stm32_set_filter(const struct zcan_filter *filter,
can_stm32_shift_bits(&device_data->response_type,
start_index,
shift_width);
}
can->FM1R = mode_reg;
can->FS1R = scale_reg;
} else {