From: Eric W. Biederman Date: Mon, 19 Jan 2015 17:48:45 +0000 (-0600) Subject: mnt: Fix the error check in __detach_mounts X-Git-Tag: v3.18.17~15 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d4bafa7be0843b63b6368ae49aaf0f5a941fc9f;p=thirdparty%2Fkernel%2Fstable.git mnt: Fix the error check in __detach_mounts [ Upstream commit f53e57975151f54ad8caa1b0ac8a78091cd5700a ] lookup_mountpoint can return either NULL or an error value. Update the test in __detach_mounts to test for an error value to avoid pathological cases causing a NULL pointer dereferences. The callers of __detach_mounts should prevent it from ever being called on an unlinked dentry but don't take any chances. Cc: stable@vger.kernel.org Signed-off-by: "Eric W. Biederman" Signed-off-by: Sasha Levin --- diff --git a/fs/namespace.c b/fs/namespace.c index 8b60287a488bc..a19d05c4ebe5f 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -1490,7 +1490,7 @@ void __detach_mounts(struct dentry *dentry) namespace_lock(); mp = lookup_mountpoint(dentry); - if (!mp) + if (IS_ERR_OR_NULL(mp)) goto out_unlock; lock_mount_hash();