diff mbox series

[ovs-dev,v3,7/8] mcast-snooping: Properly check group_get_lru return code.

Message ID 20240909045505.236657-8-mkp@redhat.com
State Accepted, archived
Commit 363435fe8c5ca4410feb6b1ae8e56479a758f2fd
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
Previously error codes from group_get_lru() were ignored, possibly
causing NULL pointer dereferencing. This patch appropriately checks for
errors.

Fixes: 4a95091d1f66 ("lib: Add IGMP snooping library bits")
Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Mike Pattrick <mkp@redhat.com>
---
 lib/mcast-snooping.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Eelco Chaudron Sept. 10, 2024, 9:57 a.m. UTC | #1
On 9 Sep 2024, at 6:55, Mike Pattrick wrote:

> Previously error codes from group_get_lru() were ignored, possibly
> causing NULL pointer dereferencing. This patch appropriately checks for
> errors.
>
> Fixes: 4a95091d1f66 ("lib: Add IGMP snooping library bits")
> 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:04AM -0400, Mike Pattrick wrote:
> Previously error codes from group_get_lru() were ignored, possibly
> causing NULL pointer dereferencing. This patch appropriately checks for
> errors.
> 
> Fixes: 4a95091d1f66 ("lib: Add IGMP snooping library bits")
> 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 dc5164b41..bf25e6f20 100644
--- a/lib/mcast-snooping.c
+++ b/lib/mcast-snooping.c
@@ -432,7 +432,9 @@  mcast_snooping_add_group(struct mcast_snooping *ms,
         uint32_t hash = mcast_table_hash(ms, addr, vlan);
 
         if (hmap_count(&ms->table) >= ms->max_entries) {
-            group_get_lru(ms, &grp);
+            if (!group_get_lru(ms, &grp)) {
+                return false;
+            }
             mcast_snooping_flush_group(ms, grp);
         }