Author: dchagin
Date: Sat May  7 18:54:35 2016
New Revision: 299219
URL: https://svnweb.freebsd.org/changeset/base/299219

Log:
  MFC r285394 (by mjg@):
  vref the vnode passed to vn_fullpath.

Modified:
  stable/10/sys/compat/linprocfs/linprocfs.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/compat/linprocfs/linprocfs.c
==============================================================================
--- stable/10/sys/compat/linprocfs/linprocfs.c  Sat May  7 18:48:48 2016        
(r299218)
+++ stable/10/sys/compat/linprocfs/linprocfs.c  Sat May  7 18:54:35 2016        
(r299219)
@@ -858,10 +858,20 @@ linprocfs_doprocstatus(PFS_FILL_ARGS)
 static int
 linprocfs_doproccwd(PFS_FILL_ARGS)
 {
+       struct filedesc *fdp;
+       struct vnode *vp;
        char *fullpath = "unknown";
        char *freepath = NULL;
 
-       vn_fullpath(td, p->p_fd->fd_cdir, &fullpath, &freepath);
+       fdp = p->p_fd;
+       FILEDESC_SLOCK(fdp);
+       vp = fdp->fd_cdir;
+       if (vp != NULL)
+               VREF(vp);
+       FILEDESC_SUNLOCK(fdp);
+       vn_fullpath(td, vp, &fullpath, &freepath);
+       if (vp != NULL)
+               vrele(vp);
        sbuf_printf(sb, "%s", fullpath);
        if (freepath)
                free(freepath, M_TEMP);
@@ -874,12 +884,20 @@ linprocfs_doproccwd(PFS_FILL_ARGS)
 static int
 linprocfs_doprocroot(PFS_FILL_ARGS)
 {
-       struct vnode *rvp;
+       struct filedesc *fdp;
+       struct vnode *vp;
        char *fullpath = "unknown";
        char *freepath = NULL;
 
-       rvp = jailed(p->p_ucred) ? p->p_fd->fd_jdir : p->p_fd->fd_rdir;
-       vn_fullpath(td, rvp, &fullpath, &freepath);
+       fdp = p->p_fd;
+       FILEDESC_SLOCK(fdp);
+       vp = jailed(p->p_ucred) ? fdp->fd_jdir : fdp->fd_rdir;
+       if (vp != NULL)
+               VREF(vp);
+       FILEDESC_SUNLOCK(fdp);
+       vn_fullpath(td, vp, &fullpath, &freepath);
+       if (vp != NULL)
+               vrele(vp);
        sbuf_printf(sb, "%s", fullpath);
        if (freepath)
                free(freepath, M_TEMP);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to