diff mbox series

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

Message ID 20240909045505.236657-4-mkp@redhat.com
State Accepted, archived
Commit cfb0abb9513fdeb0e869f9e4e4e5e531d36d5ccd
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 jsonrpc_run
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/jsonrpc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

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

> The Clang analyzer has trouble tracking the pointer usage in jsonrpc_run
> 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:25 a.m. UTC | #2
On Mon, Sep 09, 2024 at 12:55:00AM -0400, Mike Pattrick wrote:
> The Clang analyzer has trouble tracking the pointer usage in jsonrpc_run
> 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/jsonrpc.c b/lib/jsonrpc.c
index f1ef70950..2e35180f8 100644
--- a/lib/jsonrpc.c
+++ b/lib/jsonrpc.c
@@ -120,7 +120,8 @@  jsonrpc_run(struct jsonrpc *rpc)
 
     stream_run(rpc->stream);
     while (!ovs_list_is_empty(&rpc->output)) {
-        struct ofpbuf *buf = ofpbuf_from_list(rpc->output.next);
+        struct ovs_list *head = ovs_list_front(&rpc->output);
+        struct ofpbuf *buf = ofpbuf_from_list(head);
         int retval;
 
         retval = stream_send(rpc->stream, buf->data, buf->size);
@@ -128,7 +129,7 @@  jsonrpc_run(struct jsonrpc *rpc)
             rpc->backlog -= retval;
             ofpbuf_pull(buf, retval);
             if (!buf->size) {
-                ovs_list_remove(&buf->list_node);
+                ovs_list_remove(head);
                 rpc->output_count--;
                 ofpbuf_delete(buf);
             }