diff mbox series

[ovs-dev,6/7] ovsdb: Fix Coverity leak warning by marking code as unreachable.

Message ID 4f7a695fe6605cfdb676ccad17f161486fc5ba81.1749133911.git.echaudro@redhat.com
State Accepted
Commit 99af7f379107f18899ad3a082d6ffa3d755cea2b
Delegated to: aaron conole
Headers show
Series Various Coverity fixes. | 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

Eelco Chaudron June 5, 2025, 2:51 p.m. UTC
Coverity reports a memory leak on the 'error' variable in
ovsdb_trigger_try(). However, this code path is unreachable due to an
ovs_assert() in an earlier function call.

To make this clear to Coverity and silence the warning, the section is
explicitly marked as unreachable.

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 ovsdb/trigger.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Mike Pattrick June 5, 2025, 5:54 p.m. UTC | #1
On Thu, Jun 5, 2025 at 10:52 AM Eelco Chaudron via dev
<ovs-dev@openvswitch.org> wrote:
>
> Coverity reports a memory leak on the 'error' variable in
> ovsdb_trigger_try(). However, this code path is unreachable due to an
> ovs_assert() in an earlier function call.
>
> To make this clear to Coverity and silence the warning, the section is
> explicitly marked as unreachable.
>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>

Acked-by: Mike Pattrick <mkp@redhat.com>
Aaron Conole June 6, 2025, 1:56 p.m. UTC | #2
Eelco Chaudron via dev <ovs-dev@openvswitch.org> writes:

> Coverity reports a memory leak on the 'error' variable in
> ovsdb_trigger_try(). However, this code path is unreachable due to an
> ovs_assert() in an earlier function call.
>
> To make this clear to Coverity and silence the warning, the section is
> explicitly marked as unreachable.
>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> ---

ovs_assert() in an earlier function call is a bit ambiguous, and not
being as familiar with the ovsdb triggers I had to hunt around a bit to
understand which asserts you're referencing.  I think it's prevented
from the `ovsdb_trigger_init()` asserts so that a trigger should only
ever be transact or convert.  We may want to update the commit message
on apply if there isn't a reason to respin the patch.

Acked-by: Aaron Conole <aconole@redhat.com>

>  ovsdb/trigger.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c
> index 8c00fec18..173c2bb8b 100644
> --- a/ovsdb/trigger.c
> +++ b/ovsdb/trigger.c
> @@ -405,6 +405,8 @@ ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now)
>                      jsonrpc_msg_destroy(t->reply);
>                      t->reply = NULL;
>                      trigger_convert_error(t, error);
> +                } else {
> +                    OVS_NOT_REACHED();
>                  }
>              }
>          } else {
diff mbox series

Patch

diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c
index 8c00fec18..173c2bb8b 100644
--- a/ovsdb/trigger.c
+++ b/ovsdb/trigger.c
@@ -405,6 +405,8 @@  ovsdb_trigger_try(struct ovsdb_trigger *t, long long int now)
                     jsonrpc_msg_destroy(t->reply);
                     t->reply = NULL;
                     trigger_convert_error(t, error);
+                } else {
+                    OVS_NOT_REACHED();
                 }
             }
         } else {