Message ID | 20240820135549.1726748-4-mkp@redhat.com |
---|---|
State | Changes Requested, archived |
Delegated to: | Ilya Maximets |
Headers | show |
Series | Address clang analyze warnings. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | success | apply and check: success |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
On 20 Aug 2024, at 15: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. > > Signed-off-by: Mike Pattrick <mkp@redhat.com> Thanks Mike, this change looks good to me. Acked-by: Eelco Chaudron <echaudro@redhat.com>
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); }
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 <mkp@redhat.com> --- lib/jsonrpc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)