Fix nfssvc_addsock() to not attempt to free a NULL socket structure

when returning an error.  Bug fix was extracted from the PR.  The PR
    is not yet entirely resolved by this commit.

PR:		kern/13049
Reviewed by:	Matt Dillon <dillon@freebsd.org>
Submitted by:	Ian Dowse <iedowse@maths.tcd.ie>
This commit is contained in:
dillon 1999-11-08 19:10:16 +00:00
parent 0b538034b3
commit 2fb940a103
3 changed files with 18 additions and 9 deletions

View File

@ -334,6 +334,7 @@ nfssvc_addsock(fp, mynam, p)
if (so->so_proto->pr_protocol == IPPROTO_UDP) { if (so->so_proto->pr_protocol == IPPROTO_UDP) {
tslp = nfs_udpsock; tslp = nfs_udpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -341,6 +342,7 @@ nfssvc_addsock(fp, mynam, p)
} else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) {
tslp = nfs_cltpsock; tslp = nfs_cltpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -352,6 +354,7 @@ nfssvc_addsock(fp, mynam, p)
siz = NFS_MAXPACKET; siz = NFS_MAXPACKET;
error = soreserve(so, siz, siz); error = soreserve(so, siz, siz);
if (error) { if (error) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (error); return (error);
} }

View File

@ -334,6 +334,7 @@ nfssvc_addsock(fp, mynam, p)
if (so->so_proto->pr_protocol == IPPROTO_UDP) { if (so->so_proto->pr_protocol == IPPROTO_UDP) {
tslp = nfs_udpsock; tslp = nfs_udpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -341,6 +342,7 @@ nfssvc_addsock(fp, mynam, p)
} else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) {
tslp = nfs_cltpsock; tslp = nfs_cltpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -352,6 +354,7 @@ nfssvc_addsock(fp, mynam, p)
siz = NFS_MAXPACKET; siz = NFS_MAXPACKET;
error = soreserve(so, siz, siz); error = soreserve(so, siz, siz);
if (error) { if (error) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (error); return (error);
} }

View File

@ -334,6 +334,7 @@ nfssvc_addsock(fp, mynam, p)
if (so->so_proto->pr_protocol == IPPROTO_UDP) { if (so->so_proto->pr_protocol == IPPROTO_UDP) {
tslp = nfs_udpsock; tslp = nfs_udpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -341,6 +342,7 @@ nfssvc_addsock(fp, mynam, p)
} else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) {
tslp = nfs_cltpsock; tslp = nfs_cltpsock;
if (tslp->ns_flag & SLP_VALID) { if (tslp->ns_flag & SLP_VALID) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (EPERM); return (EPERM);
} }
@ -352,6 +354,7 @@ nfssvc_addsock(fp, mynam, p)
siz = NFS_MAXPACKET; siz = NFS_MAXPACKET;
error = soreserve(so, siz, siz); error = soreserve(so, siz, siz);
if (error) { if (error) {
if (mynam != NULL)
FREE(mynam, M_SONAME); FREE(mynam, M_SONAME);
return (error); return (error);
} }