mirror of https://github.com/RT-Thread/rt-thread
[components][driver][can]Fix possible memory overflow caused by RX
修复RX可能导致的内存溢出情况 #8634
This commit is contained in:
parent
befa478073
commit
15a8ebe0a0
|
@ -43,9 +43,9 @@ static rt_err_t rt_can_init(struct rt_device *dev)
|
||||||
/*
|
/*
|
||||||
* can interrupt routines
|
* 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;
|
struct rt_can_rx_fifo *rx_fifo;
|
||||||
RT_ASSERT(can != RT_NULL);
|
RT_ASSERT(can != RT_NULL);
|
||||||
size = msgs;
|
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);
|
RT_ASSERT(rx_fifo != RT_NULL);
|
||||||
|
|
||||||
/* read from software FIFO */
|
/* read from software FIFO */
|
||||||
while (msgs)
|
while (msgs / sizeof(struct rt_can_msg) > 0)
|
||||||
{
|
{
|
||||||
rt_base_t level;
|
rt_base_t level;
|
||||||
#ifdef RT_CAN_USING_HDR
|
#ifdef RT_CAN_USING_HDR
|
||||||
|
|
Loading…
Reference in New Issue