From 982b48c62a57cbbdcd48892fdd95595b72b53382 Mon Sep 17 00:00:00 2001 From: Javier Casas Date: Thu, 30 Jan 2025 10:14:40 +0100 Subject: [PATCH] bug fix: can_datahandler wrong return value can_datahandler returns an unsigned value that represent the number of bytes actually bufffered, but the call to iob_tryadd_queue returns a negative value when it fails so that value can't be used as can_datahandler return value because it is interpreted as unsigned so a big number is wrongly returned when iob_tryadd_queue fails. The fix is just setting the return value to zero when iob_tryadd_queue fails, reflecting the actual meaning that no bytes have been buffered. --- net/can/can_callback.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/can/can_callback.c b/net/can/can_callback.c index 6ea110f757a4e..cc32cfd156e0f 100644 --- a/net/can/can_callback.c +++ b/net/can/can_callback.c @@ -234,6 +234,7 @@ uint16_t can_datahandler(FAR struct net_driver_s *dev, else { nerr("ERROR: Failed to queue the I/O buffer chain: %d\n", ret); + ret = 0; goto errout; }