MFstable/11 r303691:

MFC r302550,r302551,r302552,r302553:

r302550:

Deobfuscate cleanup path in clnt_dg_create(..)

Similar to r300836 and r301800, cl and cu will always be non-NULL as they're
allocated using the mem_alloc routines, which always use
`malloc(..., M_WAITOK)`.

Deobfuscating the cleanup path fixes a leak where if cl was NULL and
cu was not, cu would not be free'd, and also removes a duplicate test for
cl not being NULL.

CID: 1007033, 1007344

r302551:

Deobfuscate cleanup path in clnt_vc_create(..)

Similar to r300836, r301800, and r302550, cl and ct will always
be non-NULL as they're allocated using the mem_alloc routines,
which always use `malloc(..., M_WAITOK)`.

CID: 1007342

r302552:

Convert `svc_xprt_alloc(..)` and `svc_xprt_free(..)`'s prototypes to
ANSI C style prototypes

r302553:

Don't test for xpt not being NULL before calling svc_xprt_free(..)

svc_xprt_alloc(..) will always return initialized memory as it uses
mem_alloc(..) under the covers, which uses malloc(.., M_WAITOK, ..).

CID: 1007341
This commit is contained in:
ngie 2016-08-03 01:19:10 +00:00
parent 41f0438c71
commit f8b9e723cd
4 changed files with 11 additions and 17 deletions

View File

@ -313,11 +313,9 @@ recheck_socket:
cl->cl_netid = NULL;
return (cl);
err2:
if (cl) {
mem_free(cl, sizeof (CLIENT));
if (cu)
mem_free(cu, sizeof (*cu));
}
mem_free(cl, sizeof (CLIENT));
mem_free(cu, sizeof (*cu));
return (NULL);
}

View File

@ -270,12 +270,10 @@ clnt_vc_create(
return (cl);
err:
if (ct) {
mtx_destroy(&ct->ct_lock);
mem_free(ct, sizeof (struct ct_data));
}
if (cl)
mem_free(cl, sizeof (CLIENT));
mtx_destroy(&ct->ct_lock);
mem_free(ct, sizeof (struct ct_data));
mem_free(cl, sizeof (CLIENT));
return ((CLIENT *)NULL);
}

View File

@ -841,7 +841,7 @@ svcerr_progvers(struct svc_req *rqstp, rpcvers_t low_vers, rpcvers_t high_vers)
* parameters.
*/
SVCXPRT *
svc_xprt_alloc()
svc_xprt_alloc(void)
{
SVCXPRT *xprt;
SVCXPRT_EXT *ext;
@ -858,8 +858,7 @@ svc_xprt_alloc()
* Free a server transport structure.
*/
void
svc_xprt_free(xprt)
SVCXPRT *xprt;
svc_xprt_free(SVCXPRT *xprt)
{
mem_free(xprt->xp_p3, sizeof(SVCXPRT_EXT));

View File

@ -142,9 +142,8 @@ svc_dg_create(SVCPOOL *pool, struct socket *so, size_t sendsize,
return (xprt);
freedata:
(void) printf(svc_dg_str, __no_mem_str);
if (xprt) {
svc_xprt_free(xprt);
}
svc_xprt_free(xprt);
return (NULL);
}