diff mbox series

[ovs-dev,8/8] mcast-snooping: Don't access ovs_list members directly

Message ID 20240820131444.1724438-9-mkp@redhat.com
State Superseded, archived
Headers show
Series Address clang analyze warnings. | expand

Checks

Context Check Description
ovsrobot/apply-robot warning apply and check: warning
ovsrobot/github-robot-_Build_and_Test success github build: passed

Commit Message

Mike Pattrick Aug. 20, 2024, 1:14 p.m. UTC
The Clang analyzer has trouble tracking the pointer usage in
mrouter_get_lru and will report a use after free incorrectly. This patch
migrates to using standard ovs_list functions instead of directly
accessing the next member, which supresses clang's warning.

Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 lib/mcast-snooping.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Simon Horman Aug. 28, 2024, 10:50 a.m. UTC | #1
On Tue, Aug 20, 2024 at 09:14:44AM -0400, Mike Pattrick wrote:
> The Clang analyzer has trouble tracking the pointer usage in
> mrouter_get_lru and will report a use after free incorrectly. This patch
> migrates to using standard ovs_list functions instead of directly
> accessing the next member, which supresses clang's warning.
> 
> Signed-off-by: Mike Pattrick <mkp@redhat.com>

Acked-by: Simon Horman <horms@ovn.org>
Simon Horman Aug. 28, 2024, 10:58 a.m. UTC | #2
On Tue, Aug 20, 2024 at 09:14:44AM -0400, Mike Pattrick wrote:
> The Clang analyzer has trouble tracking the pointer usage in
> mrouter_get_lru and will report a use after free incorrectly. This patch
> migrates to using standard ovs_list functions instead of directly
> accessing the next member, which supresses clang's warning.
> 
> Signed-off-by: Mike Pattrick <mkp@redhat.com>

Acked-by: Simon Horman <horms@ovn.org>
diff mbox series

Patch

diff --git a/lib/mcast-snooping.c b/lib/mcast-snooping.c
index bf25e6f20..b279c1229 100644
--- a/lib/mcast-snooping.c
+++ b/lib/mcast-snooping.c
@@ -653,7 +653,7 @@  mrouter_get_lru(const struct mcast_snooping *ms,
     OVS_REQ_RDLOCK(ms->rwlock)
 {
     if (!ovs_list_is_empty(&ms->mrouter_lru)) {
-        *m = mcast_mrouter_from_lru_node(ms->mrouter_lru.next);
+        *m = mcast_mrouter_from_lru_node(ovs_list_front(&ms->mrouter_lru));
         return true;
     } else {
         *m = NULL;
@@ -726,7 +726,7 @@  mcast_snooping_port_get(const struct ovs_list *list,
                         struct mcast_port_bundle **f)
 {
     if (!ovs_list_is_empty(list)) {
-        *f = mcast_port_from_list_node(list->next);
+        *f = mcast_port_from_list_node(ovs_list_front(list));
         return true;
     } else {
         *f = NULL;