net/colo-compare.c: Fix memory leak and code style issue.
PATCH v5 1/1 net/colo-compare.c: Fix memory leak and code style issue.
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)
--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
net/colo-compare.c +20 -7
@@ -127,6 +127,17 @@ static int compare_chr_send(CompareState *s,uint32_t vnet_hdr_len, bool notify_remote_frame); +static bool packet_matches_str (const char *str, +const uint8_t *buf, +uint32_t packet_len) +{ +if (packet_len !=strlen (str)) { +return false; + } + +return !memcmp (str, buf,strlen (str)); +} +static void notify_remote_frame (CompareState *s) {char msg[] ="DO_CHECKPOINT" ;
@@ -1008,21 +1019,23 @@ static void compare_notify_rs_finalize(SocketReadState *notify_rs) {CompareState *s =container_of (notify_rs, CompareState, notify_rs); -/* Get Xen colo-frame's notify and handle the message */ -char *data =g_memdup (notify_rs->buf, notify_rs->packet_len); -char msg[] ="COLO_COMPARE_GET_XEN_INIT" ; +const char msg[] ="COLO_COMPARE_GET_XEN_INIT" ;int ret; -if (!strcmp (data,"COLO_USERSPACE_PROXY_INIT" )) { +if (packet_matches_str ("COLO_USERSPACE_PROXY_INIT" , + notify_rs->buf, + notify_rs->packet_len)) { ret =compare_chr_send (s, (uint8_t *)msg,strlen (msg),0 , true);if (ret <0 ) {error_report ("Notify Xen COLO-frame INIT failed" ); } - } - -if (!strcmp (data,"COLO_CHECKPOINT" )) { + }else if (packet_matches_str ("COLO_CHECKPOINT" , + notify_rs->buf, + notify_rs->packet_len)) {/* colo-compare do checkpoint, flush pri packet and remove sec packet */ g_queue_foreach (&s->conn_list, colo_flush_packets, s); + }else { +error_report ("COLO compare got unsupported instruction" ); } }
Signature · 1 line
2.17.GIT
Quoted 11 lines · Zhang Chen
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
Thanks for your patience in sending out all these versions as we worked through the code review process.
thanks
-- PMM
Quoted 25 lines
-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Tuesday, July 23, 2019 1:25 AM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Jason Wang <[email protected]>; qemu-dev <[email protected]>; Zhang Chen <[email protected]>
Subject: Re: [PATCH V5]net/colo-compare.c: Fix memory leak and code style issue.Quoted 11 lines · Zhang Chen
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
Quoted 4 lines
Reviewed-by Peter Maydell <[email protected]>Thanks for your patience in sending out all these versions as we worked through the code review process.
Thank you too~
Maybe you or Jason can pick up this patch?
Thanks
Zhang Chen
Quoted 3 lines
thanks
-- PMM
Jason Wang
AppliedQuoted 24 lines · Chen
Quoted 24 lines
-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Tuesday, July 23, 2019 1:25 AM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Jason Wang <[email protected]>; qemu-dev <[email protected]>; Zhang Chen <[email protected]>
Subject: Re: [PATCH V5]net/colo-compare.c: Fix memory leak and code style issue.Quoted 10 lines · Zhang Chen
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)Reviewed-by Peter Maydell <[email protected]>
Quoted 7 lines
Quoted 2 lines
Thanks for your patience in sending out all these versions as we worked through the code review process.
Thank you too~
Maybe you or Jason can pick up this patch?Thanks
Zhang Chen
Applied.
Thanks
Quoted 3 lines
Quoted 3 lines
thanks
-- PMM
Quoted 25 lines · Jason Wang
Quoted 22 lines · Chen
Quoted 22 lines
-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Tuesday, July 23, 2019 1:25 AM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Jason Wang <[email protected]>; qemu-dev <[email protected]>; Zhang Chen <[email protected]>
Subject: Re: [PATCH V5]net/colo-compare.c: Fix memory leak and code style issue.Quoted 10 lines · Zhang Chen
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
Reviewed-by Peter Maydell <[email protected]>Thanks for your patience in sending out all these versions as we worked through the code review process.
Thank you too~
Maybe you or Jason can pick up this patch?Applied.
Thanks. This is now our last outstanding coverity issue -- are you planning to send this in for rc3 ?
-- PMM
----- Original Message -----
Quoted 35 lines · Jason Wang
Quoted 33 lines · Chen
Quoted 30 lines
Quoted 20 lines
-----Original Message-----
From: Peter Maydell [mailto:[email protected]]
Sent: Tuesday, July 23, 2019 1:25 AM
To: Zhang, Chen <[email protected]>
Cc: Li Zhijian <[email protected]>; Jason Wang <[email protected]>;
qemu-dev <[email protected]>; Zhang Chen <[email protected]>
Subject: Re: [PATCH V5]net/colo-compare.c: Fix memory leak and code style
issue.Quoted 6 lines · Zhang Chen
From: Zhang Chen <[email protected]>
This patch to fix the origin "char *data" memory leak, code style issue and add necessary check here.
Reported-by: Coverity (CID 1402785)Quoted 8 lines
Quoted 4 lines
Signed-off-by Zhang Chen <[email protected]>--- net/colo-compare.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-)Reviewed-by Peter Maydell <[email protected]>Thanks for your patience in sending out all these versions as we worked through the code review process.
Thank you too~
Maybe you or Jason can pick up this patch?
Quoted 8 lines
Quoted 1 line
Applied.
Thanks. This is now our last outstanding coverity issue -- are you planning to send this in for rc3 ?
-- PMM
Yes.
Thanks