Message ID | 20180907180151.178872-5-steved@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | libtirpc: Closed a number of memory leaks | expand |
On Fri, 2018-09-07 at 14:01 -0400, Steve Dickson wrote: > Variable "ct" going out of scope leaks the storage it points to. > > Signed-off-by: Steve Dickson <steved@redhat.com> > --- > src/clnt_vc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/src/clnt_vc.c b/src/clnt_vc.c > index 3d775c7..10ee91a 100644 > --- a/src/clnt_vc.c > +++ b/src/clnt_vc.c > @@ -325,6 +325,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) > recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); > xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, > cl->cl_private, read_vc, write_vc); > + mem_free(ct->ct_addr.buf, ct->ct_addr.len); > + mem_free(ct, sizeof (struct ct_data)); > return (cl); > > err: Are you sure about this one Steve? aka: /* * Create a client handle which uses xdrrec for serialization * and authnone for authentication. */ cl->cl_ops = clnt_vc_ops(); cl->cl_private = ct; <------? cl->cl_auth = authnone_create(); sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz); recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, cl->cl_private, read_vc, write_vc); return (cl);
On Mon, 2018-10-29 at 14:24 +0800, Ian Kent wrote: > On Fri, 2018-09-07 at 14:01 -0400, Steve Dickson wrote: > > Variable "ct" going out of scope leaks the storage it points to. > > > > Signed-off-by: Steve Dickson <steved@redhat.com> > > --- > > src/clnt_vc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/src/clnt_vc.c b/src/clnt_vc.c > > index 3d775c7..10ee91a 100644 > > --- a/src/clnt_vc.c > > +++ b/src/clnt_vc.c > > @@ -325,6 +325,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) > > recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); > > xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, > > cl->cl_private, read_vc, write_vc); > > + mem_free(ct->ct_addr.buf, ct->ct_addr.len); > > + mem_free(ct, sizeof (struct ct_data)); > > return (cl); > > > > err: > > Are you sure about this one Steve? > > aka: > /* > * Create a client handle which uses xdrrec for serialization > * and authnone for authentication. > */ > cl->cl_ops = clnt_vc_ops(); > cl->cl_private = ct; <------? > cl->cl_auth = authnone_create(); > sendsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)sendsz); > recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); > xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, > cl->cl_private, read_vc, write_vc); > return (cl); Oh! My bad, reverted in commit e49077d2fa.
diff --git a/src/clnt_vc.c b/src/clnt_vc.c index 3d775c7..10ee91a 100644 --- a/src/clnt_vc.c +++ b/src/clnt_vc.c @@ -325,6 +325,8 @@ clnt_vc_create(fd, raddr, prog, vers, sendsz, recvsz) recvsz = __rpc_get_t_size(si.si_af, si.si_proto, (int)recvsz); xdrrec_create(&(ct->ct_xdrs), sendsz, recvsz, cl->cl_private, read_vc, write_vc); + mem_free(ct->ct_addr.buf, ct->ct_addr.len); + mem_free(ct, sizeof (struct ct_data)); return (cl); err:
Variable "ct" going out of scope leaks the storage it points to. Signed-off-by: Steve Dickson <steved@redhat.com> --- src/clnt_vc.c | 2 ++ 1 file changed, 2 insertions(+)