diff mbox series

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

Message ID 20240909045505.236657-9-mkp@redhat.com
State Accepted, archived
Commit ddd6490abdb41e9737ba1b0c7e42a6da7596326d
Delegated to: Eelco Chaudron
Headers show
Series Address clang analyze warnings. | expand

Checks

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

Commit Message

Mike Pattrick Sept. 9, 2024, 4:55 a.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 suppresses clang's warning.

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

Comments

Eelco Chaudron Sept. 10, 2024, 9:57 a.m. UTC | #1
On 9 Sep 2024, at 6:55, 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 suppresses clang's warning.
>
> Acked-by: Eelco Chaudron <echaudro@redhat.com>
> Signed-off-by: Mike Pattrick <mkp@redhat.com>

Thanks for sending out the v3, the changes look good to me.

Cheers,

Eelco

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Simon Horman Sept. 11, 2024, 9:24 a.m. UTC | #2
On Mon, Sep 09, 2024 at 12:55:05AM -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 suppresses clang's warning.
> 
> Acked-by: Eelco Chaudron <echaudro@redhat.com>
> 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;