From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55117) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c0ozV-0007OY-Dt for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:13:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c0ozS-0004k8-8E for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:13:33 -0400 Received: from 10.mo5.mail-out.ovh.net ([46.105.52.148]:33817) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c0ozR-0004jz-Vh for qemu-devel@nongnu.org; Sun, 30 Oct 2016 08:13:30 -0400 Received: from player774.ha.ovh.net (b7.ovh.net [213.186.33.57]) by mo5.mail-out.ovh.net (Postfix) with ESMTP id 72CAC4042D for ; Sun, 30 Oct 2016 13:13:27 +0100 (CET) Date: Sun, 30 Oct 2016 13:13:23 +0100 From: Greg Kurz Message-ID: <20161030131323.7dc17bcd@bahia> In-Reply-To: <1477448651-4474-10-git-send-email-jasowang@redhat.com> References: <1477448651-4474-1-git-send-email-jasowang@redhat.com> <1477448651-4474-10-git-send-email-jasowang@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PULL 9/9] colo-proxy: fix memory leak List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jason Wang Cc: qemu-devel@nongnu.org, peter.maydell@linaro.org, Zhang Chen On Wed, 26 Oct 2016 10:24:11 +0800 Jason Wang wrote: > From: Zhang Chen >=20 > Fix memory leak in colo-compare.c and filter-rewriter.c > Report by Coverity and add some comments. >=20 > Signed-off-by: Zhang Chen > Reviewed-by: zhanghailiang > Signed-off-by: Jason Wang > --- Hi, This commit breaks --enable-trace-backends=3Dust builds in travis (#17): In file included from ./trace/generated-tracers.h:5966:0, from /home/travis/build/gkurz/qemu/include/trace.h:4, from qapi/qapi-visit-core.c:22: ./trace/generated-ust-provider.h:18625:3: error: unknown type name =E2=80= =98_TP_EXPROTOint=E2=80=99 In file included from /home/travis/build/gkurz/qemu/include/trace.h:4:0, from qapi/qapi-visit-core.c:22: ./trace/generated-tracers.h: In function =E2=80=98trace_colo_compare_pkt_in= fo=E2=80=99: ./trace/generated-tracers.h:19249:432: error: expected string literal befor= e =E2=80=98_SDT_ASM_OPERANDS_ssize=E2=80=99 ./trace/generated-tracers.h:19249:432: error: implicit declaration of funct= ion =E2=80=98__tracepoint_cb_qemu___colo_compare_pkt_info=E2=80=99 [-Werror= =3Dimplicit-function-declaration] ./trace/generated-tracers.h:19249:432: error: nested extern declaration of = =E2=80=98__tracepoint_cb_qemu___colo_compare_pkt_info=E2=80=99 [-Werror=3Dn= ested-externs] cc1: all warnings being treated as errors make: *** [qapi/qapi-visit-core.o] Error 1 make: *** Waiting for unfinished jobs.... https://travis-ci.org/gkurz/qemu/jobs/171641119 Cheers. -- Greg > net/colo-compare.c | 34 +++++++++++++++------------------- > net/filter-rewriter.c | 17 +++++------------ > net/trace-events | 1 + > 3 files changed, 21 insertions(+), 31 deletions(-) >=20 > diff --git a/net/colo-compare.c b/net/colo-compare.c > index 109990f..f791383 100644 > --- a/net/colo-compare.c > +++ b/net/colo-compare.c > @@ -188,7 +188,6 @@ static int colo_packet_compare_tcp(Packet *spkt, Pack= et *ppkt) > { > struct tcphdr *ptcp, *stcp; > int res; > - char *sdebug, *ddebug; > =20 > trace_colo_compare_main("compare tcp"); > if (ppkt->size !=3D spkt->size) { > @@ -219,24 +218,21 @@ static int colo_packet_compare_tcp(Packet *spkt, Pa= cket *ppkt) > (spkt->size - ETH_HLEN)); > =20 > if (res !=3D 0 && trace_event_get_state(TRACE_COLO_COMPARE_MISCOMPAR= E)) { > - sdebug =3D strdup(inet_ntoa(ppkt->ip->ip_src)); > - ddebug =3D strdup(inet_ntoa(ppkt->ip->ip_dst)); > - fprintf(stderr, "%s: src/dst: %s/%s p: seq/ack=3D%u/%u" > - " s: seq/ack=3D%u/%u res=3D%d flags=3D%x/%x\n", > - __func__, sdebug, ddebug, > - (unsigned int)ntohl(ptcp->th_seq), > - (unsigned int)ntohl(ptcp->th_ack), > - (unsigned int)ntohl(stcp->th_seq), > - (unsigned int)ntohl(stcp->th_ack), > - res, ptcp->th_flags, stcp->th_flags); > - > - fprintf(stderr, "Primary len =3D %d\n", ppkt->size); > - qemu_hexdump((char *)ppkt->data, stderr, "colo-compare", ppkt->s= ize); > - fprintf(stderr, "Secondary len =3D %d\n", spkt->size); > - qemu_hexdump((char *)spkt->data, stderr, "colo-compare", spkt->s= ize); > - > - g_free(sdebug); > - g_free(ddebug); > + trace_colo_compare_pkt_info(inet_ntoa(ppkt->ip->ip_src), > + inet_ntoa(ppkt->ip->ip_dst), > + ntohl(ptcp->th_seq), > + ntohl(ptcp->th_ack), > + ntohl(stcp->th_seq), > + ntohl(stcp->th_ack), > + res, ptcp->th_flags, > + stcp->th_flags, > + ppkt->size, > + spkt->size); > + > + qemu_hexdump((char *)ppkt->data, stderr, > + "colo-compare ppkt", ppkt->size); > + qemu_hexdump((char *)spkt->data, stderr, > + "colo-compare spkt", spkt->size); > } > =20 > return res; > diff --git a/net/filter-rewriter.c b/net/filter-rewriter.c > index 89abe72..c4ab91c 100644 > --- a/net/filter-rewriter.c > +++ b/net/filter-rewriter.c > @@ -68,15 +68,11 @@ static int handle_primary_tcp_pkt(NetFilterState *nf, > =20 > tcp_pkt =3D (struct tcphdr *)pkt->transport_header; > if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) { > - char *sdebug, *ddebug; > - sdebug =3D strdup(inet_ntoa(pkt->ip->ip_src)); > - ddebug =3D strdup(inet_ntoa(pkt->ip->ip_dst)); > - trace_colo_filter_rewriter_pkt_info(__func__, sdebug, ddebug, > + trace_colo_filter_rewriter_pkt_info(__func__, > + inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_ds= t), > ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), > tcp_pkt->th_flags); > trace_colo_filter_rewriter_conn_offset(conn->offset); > - g_free(sdebug); > - g_free(ddebug); > } > =20 > if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D TH_SYN)) { > @@ -116,15 +112,11 @@ static int handle_secondary_tcp_pkt(NetFilterState = *nf, > tcp_pkt =3D (struct tcphdr *)pkt->transport_header; > =20 > if (trace_event_get_state(TRACE_COLO_FILTER_REWRITER_DEBUG)) { > - char *sdebug, *ddebug; > - sdebug =3D strdup(inet_ntoa(pkt->ip->ip_src)); > - ddebug =3D strdup(inet_ntoa(pkt->ip->ip_dst)); > - trace_colo_filter_rewriter_pkt_info(__func__, sdebug, ddebug, > + trace_colo_filter_rewriter_pkt_info(__func__, > + inet_ntoa(pkt->ip->ip_src), inet_ntoa(pkt->ip->ip_ds= t), > ntohl(tcp_pkt->th_seq), ntohl(tcp_pkt->th_ack), > tcp_pkt->th_flags); > trace_colo_filter_rewriter_conn_offset(conn->offset); > - g_free(sdebug); > - g_free(ddebug); > } > =20 > if (((tcp_pkt->th_flags & (TH_ACK | TH_SYN)) =3D=3D (TH_ACK | TH_SYN= ))) { > @@ -162,6 +154,7 @@ static ssize_t colo_rewriter_receive_iov(NetFilterSta= te *nf, > =20 > iov_to_buf(iov, iovcnt, 0, buf, size); > pkt =3D packet_new(buf, size); > + g_free(buf); > =20 > /* > * if we get tcp packet > diff --git a/net/trace-events b/net/trace-events > index d67f048..b1913a6 100644 > --- a/net/trace-events > +++ b/net/trace-events > @@ -13,6 +13,7 @@ colo_compare_icmp_miscompare(const char *sta, int size)= ": %s =3D %d" > colo_compare_ip_info(int psize, const char *sta, const char *stb, int ss= ize, const char *stc, const char *std) "ppkt size =3D %d, ip_src =3D %s, ip= _dst =3D %s, spkt size =3D %d, ip_src =3D %s, ip_dst =3D %s" > colo_old_packet_check_found(int64_t old_time) "%" PRId64 > colo_compare_miscompare(void) "" > +colo_compare_pkt_info(const char *src, const char *dst, uint32_t pseq, u= int32_t pack, uint32_t sseq, uint32_t sack, int res, uint32_t pflag, uint32= _t sflag, int psize, int ssize) "src/dst: %s/%s p: seq/ack=3D%u/%u s: seq= /ack=3D%u/%u res=3D%d flags=3D%x/%x ppkt_size: %d spkt_size: %d\n" > =20 > # net/filter-rewriter.c > colo_filter_rewriter_debug(void) ""