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.

Signed-off-by: Mike Pattrick <m...@redhat.com>
---
 lib/jsonrpc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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);
             }
-- 
2.43.5

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to