* [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
@ 2019-07-22 17:18 Zhang Chen
2019-07-22 17:24 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Chen @ 2019-07-22 17:18 UTC (permalink / raw)
To: Li Zhijian, Peter Maydell, Jason Wang, qemu-dev; +Cc: Zhang Chen, Zhang Chen
From: Zhang Chen <chen.zhang@intel.com>
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 <chen.zhang@intel.com>
---
net/colo-compare.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 909dd6c6eb..7489840bde 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -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");
}
}
--
2.17.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
2019-07-22 17:18 [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue Zhang Chen
@ 2019-07-22 17:24 ` Peter Maydell
2019-07-22 18:38 ` Zhang, Chen
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2019-07-22 17:24 UTC (permalink / raw)
To: Zhang Chen; +Cc: Jason Wang, qemu-dev, Li Zhijian, Zhang Chen
On Mon, 22 Jul 2019 at 18:23, Zhang Chen <chen.zhang@intel.com> wrote:
>
> From: Zhang Chen <chen.zhang@intel.com>
>
> 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 <chen.zhang@intel.com>
> ---
> net/colo-compare.c | 27 ++++++++++++++++++++-------
> 1 file changed, 20 insertions(+), 7 deletions(-)
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Thanks for your patience in sending out all these versions
as we worked through the code review process.
thanks
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
2019-07-22 17:24 ` Peter Maydell
@ 2019-07-22 18:38 ` Zhang, Chen
2019-07-23 3:23 ` Jason Wang
0 siblings, 1 reply; 6+ messages in thread
From: Zhang, Chen @ 2019-07-22 18:38 UTC (permalink / raw)
To: Peter Maydell; +Cc: Jason Wang, qemu-dev, Li Zhijian, Zhang Chen
> -----Original Message-----
> From: Peter Maydell [mailto:peter.maydell@linaro.org]
> Sent: Tuesday, July 23, 2019 1:25 AM
> To: Zhang, Chen <chen.zhang@intel.com>
> Cc: Li Zhijian <lizhijian@cn.fujitsu.com>; Jason Wang <jasowang@redhat.com>;
> qemu-dev <qemu-devel@nongnu.org>; Zhang Chen <zhangckid@gmail.com>
> Subject: Re: [PATCH V5] net/colo-compare.c: Fix memory leak and code style
> issue.
>
> On Mon, 22 Jul 2019 at 18:23, Zhang Chen <chen.zhang@intel.com> wrote:
> >
> > From: Zhang Chen <chen.zhang@intel.com>
> >
> > 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 <chen.zhang@intel.com>
> > ---
> > net/colo-compare.c | 27 ++++++++++++++++++++-------
> > 1 file changed, 20 insertions(+), 7 deletions(-)
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> 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
>
> thanks
> -- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
2019-07-22 18:38 ` Zhang, Chen
@ 2019-07-23 3:23 ` Jason Wang
2019-07-25 9:27 ` Peter Maydell
0 siblings, 1 reply; 6+ messages in thread
From: Jason Wang @ 2019-07-23 3:23 UTC (permalink / raw)
To: Zhang, Chen, Peter Maydell; +Cc: qemu-dev, Li Zhijian, Zhang Chen
On 2019/7/23 上午2:38, Zhang, Chen wrote:
>
>
>> -----Original Message-----
>> From: Peter Maydell [mailto:peter.maydell@linaro.org]
>> Sent: Tuesday, July 23, 2019 1:25 AM
>> To: Zhang, Chen <chen.zhang@intel.com>
>> Cc: Li Zhijian <lizhijian@cn.fujitsu.com>; Jason Wang <jasowang@redhat.com>;
>> qemu-dev <qemu-devel@nongnu.org>; Zhang Chen <zhangckid@gmail.com>
>> Subject: Re: [PATCH V5] net/colo-compare.c: Fix memory leak and code style
>> issue.
>>
>> On Mon, 22 Jul 2019 at 18:23, Zhang Chen <chen.zhang@intel.com> wrote:
>>> From: Zhang Chen <chen.zhang@intel.com>
>>>
>>> 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 <chen.zhang@intel.com>
>>> ---
>>> net/colo-compare.c | 27 ++++++++++++++++++++-------
>>> 1 file changed, 20 insertions(+), 7 deletions(-)
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>>
>> 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
>
>> thanks
>> -- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
2019-07-23 3:23 ` Jason Wang
@ 2019-07-25 9:27 ` Peter Maydell
2019-07-25 9:31 ` Jason Wang
0 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2019-07-25 9:27 UTC (permalink / raw)
To: Jason Wang; +Cc: Zhang, Chen, qemu-dev, Li Zhijian, Zhang Chen
On Tue, 23 Jul 2019 at 04:24, Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2019/7/23 上午2:38, Zhang, Chen wrote:
> >
> >
> >> -----Original Message-----
> >> From: Peter Maydell [mailto:peter.maydell@linaro.org]
> >> Sent: Tuesday, July 23, 2019 1:25 AM
> >> To: Zhang, Chen <chen.zhang@intel.com>
> >> Cc: Li Zhijian <lizhijian@cn.fujitsu.com>; Jason Wang <jasowang@redhat.com>;
> >> qemu-dev <qemu-devel@nongnu.org>; Zhang Chen <zhangckid@gmail.com>
> >> Subject: Re: [PATCH V5] net/colo-compare.c: Fix memory leak and code style
> >> issue.
> >>
> >> On Mon, 22 Jul 2019 at 18:23, Zhang Chen <chen.zhang@intel.com> wrote:
> >>> From: Zhang Chen <chen.zhang@intel.com>
> >>>
> >>> 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 <chen.zhang@intel.com>
> >>> ---
> >>> net/colo-compare.c | 27 ++++++++++++++++++++-------
> >>> 1 file changed, 20 insertions(+), 7 deletions(-)
> >> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> >>
> >> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue.
2019-07-25 9:27 ` Peter Maydell
@ 2019-07-25 9:31 ` Jason Wang
0 siblings, 0 replies; 6+ messages in thread
From: Jason Wang @ 2019-07-25 9:31 UTC (permalink / raw)
To: Peter Maydell; +Cc: Chen Zhang, qemu-dev, Li Zhijian, Zhang Chen
----- Original Message -----
> On Tue, 23 Jul 2019 at 04:24, Jason Wang <jasowang@redhat.com> wrote:
> >
> >
> > On 2019/7/23 上午2:38, Zhang, Chen wrote:
> > >
> > >
> > >> -----Original Message-----
> > >> From: Peter Maydell [mailto:peter.maydell@linaro.org]
> > >> Sent: Tuesday, July 23, 2019 1:25 AM
> > >> To: Zhang, Chen <chen.zhang@intel.com>
> > >> Cc: Li Zhijian <lizhijian@cn.fujitsu.com>; Jason Wang
> > >> <jasowang@redhat.com>;
> > >> qemu-dev <qemu-devel@nongnu.org>; Zhang Chen <zhangckid@gmail.com>
> > >> Subject: Re: [PATCH V5] net/colo-compare.c: Fix memory leak and code
> > >> style
> > >> issue.
> > >>
> > >> On Mon, 22 Jul 2019 at 18:23, Zhang Chen <chen.zhang@intel.com> wrote:
> > >>> From: Zhang Chen <chen.zhang@intel.com>
> > >>>
> > >>> 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 <chen.zhang@intel.com>
> > >>> ---
> > >>> net/colo-compare.c | 27 ++++++++++++++++++++-------
> > >>> 1 file changed, 20 insertions(+), 7 deletions(-)
> > >> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> > >>
> > >> 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
>
>
Yes.
Thanks
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-07-25 9:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-22 17:18 [Qemu-devel] [PATCH V5] net/colo-compare.c: Fix memory leak and code style issue Zhang Chen
2019-07-22 17:24 ` Peter Maydell
2019-07-22 18:38 ` Zhang, Chen
2019-07-23 3:23 ` Jason Wang
2019-07-25 9:27 ` Peter Maydell
2019-07-25 9:31 ` Jason Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).