[components][driver][can]Fix possible memory overflow caused by RX

修复RX可能导致的内存溢出情况

#8634
This commit is contained in:
wdfk-prog 2024-07-09 20:22:37 +08:00 committed by GitHub
parent befa478073
commit 15a8ebe0a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 3 additions and 3 deletions

View File

@ -43,9 +43,9 @@ static rt_err_t rt_can_init(struct rt_device *dev)
/*
* can interrupt routines
*/
rt_inline int _can_int_rx(struct rt_can_device *can, struct rt_can_msg *data, int msgs)
rt_inline rt_ssize_t _can_int_rx(struct rt_can_device *can, struct rt_can_msg *data, rt_ssize_t msgs)
{
int size;
rt_ssize_t size;
struct rt_can_rx_fifo *rx_fifo;
RT_ASSERT(can != RT_NULL);
size = msgs;
@ -54,7 +54,7 @@ rt_inline int _can_int_rx(struct rt_can_device *can, struct rt_can_msg *data, in
RT_ASSERT(rx_fifo != RT_NULL);
/* read from software FIFO */
while (msgs)
while (msgs / sizeof(struct rt_can_msg) > 0)
{
rt_base_t level;
#ifdef RT_CAN_USING_HDR