From 6b21e946048a8b45033d78a6978c78ef33202ee1 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 8 Nov 1999 19:10:16 +0000 Subject: [PATCH] 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 Submitted by: Ian Dowse --- sys/nfs/nfs_syscalls.c | 9 ++++++--- sys/nfsclient/nfs_nfsiod.c | 9 ++++++--- sys/nfsserver/nfs_syscalls.c | 9 ++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 054950bd3a1b..ff2efe5dc28a 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -334,14 +334,16 @@ nfssvc_addsock(fp, mynam, p) if (so->so_proto->pr_protocol == IPPROTO_UDP) { tslp = nfs_udpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #ifdef ISO } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { tslp = nfs_cltpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #endif /* ISO */ @@ -352,7 +354,8 @@ nfssvc_addsock(fp, mynam, p) siz = NFS_MAXPACKET; error = soreserve(so, siz, siz); if (error) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (error); } diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index 054950bd3a1b..ff2efe5dc28a 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -334,14 +334,16 @@ nfssvc_addsock(fp, mynam, p) if (so->so_proto->pr_protocol == IPPROTO_UDP) { tslp = nfs_udpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #ifdef ISO } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { tslp = nfs_cltpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #endif /* ISO */ @@ -352,7 +354,8 @@ nfssvc_addsock(fp, mynam, p) siz = NFS_MAXPACKET; error = soreserve(so, siz, siz); if (error) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (error); } diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 054950bd3a1b..ff2efe5dc28a 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -334,14 +334,16 @@ nfssvc_addsock(fp, mynam, p) if (so->so_proto->pr_protocol == IPPROTO_UDP) { tslp = nfs_udpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #ifdef ISO } else if (so->so_proto->pr_protocol == ISOPROTO_CLTP) { tslp = nfs_cltpsock; if (tslp->ns_flag & SLP_VALID) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (EPERM); } #endif /* ISO */ @@ -352,7 +354,8 @@ nfssvc_addsock(fp, mynam, p) siz = NFS_MAXPACKET; error = soreserve(so, siz, siz); if (error) { - FREE(mynam, M_SONAME); + if (mynam != NULL) + FREE(mynam, M_SONAME); return (error); }