From d8b10ae379d28591ba188382eb605fd10b872122 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Fri, 2 Dec 2016 13:57:02 -0800 Subject: [PATCH] kernel - Fix smbfs readdir and umount * Fix a bug in smbfs's readdir that was causing an empty list and also a later deadlock. * Fix a bug in smbfs's umount that was panicing the machine. --- sys/vfs/smbfs/smbfs_vfsops.c | 4 ++++ sys/vfs/smbfs/smbfs_vnops.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/vfs/smbfs/smbfs_vfsops.c b/sys/vfs/smbfs/smbfs_vfsops.c index e7e531b2ad..c24dc4f18f 100644 --- a/sys/vfs/smbfs/smbfs_vfsops.c +++ b/sys/vfs/smbfs/smbfs_vfsops.c @@ -234,6 +234,9 @@ smbfs_unmount(struct mount *mp, int mntflags) if (error) return error; smb_makescred(&scred, curthread, smp->sm_cred); + error = smb_share_lock(smp->sm_share, LK_EXCLUSIVE); + if (error) + goto out; smb_share_put(smp->sm_share, &scred); mp->mnt_data = (qaddr_t)0; @@ -244,6 +247,7 @@ smbfs_unmount(struct mount *mp, int mntflags) lockdestroy(&smp->sm_hashlock); kfree(smp, M_SMBFSDATA); mp->mnt_flag &= ~MNT_LOCAL; +out: return error; } diff --git a/sys/vfs/smbfs/smbfs_vnops.c b/sys/vfs/smbfs/smbfs_vnops.c index d9c70b438a..47ca6bd6f3 100644 --- a/sys/vfs/smbfs/smbfs_vnops.c +++ b/sys/vfs/smbfs/smbfs_vnops.c @@ -714,7 +714,7 @@ smbfs_readdir(struct vop_readdir_args *ap) } #endif error = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY | LK_FAILRECLAIM); - if (error) { + if (error == 0) { error = smbfs_readvnode(vp, uio, ap->a_cred); vn_unlock(vp); } -- 2.11.4.GIT