diff --git a/fs/unionfs/copyup.c b/fs/unionfs/copyup.c
index c43cc7f..9d7468f 100644
--- a/fs/unionfs/copyup.c
+++ b/fs/unionfs/copyup.c
@@ -498,7 +498,7 @@ out_unlink:
 	 */
 	vfs_unlink(new_lower_parent_dentry->d_inode, new_lower_dentry);
 
-	if (copyup_file) {
+	if (copyup_file && *copyup_file) {
 		/* need to close the file */
 
 		fput(*copyup_file);
diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index bd5a3b3..6b2f16f 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -918,11 +918,18 @@ static int unionfs_setattr(struct dentry *dentry, struct iattr *ia)
 
 	lower_dentry = unionfs_lower_dentry(dentry);
 	if (!lower_dentry) { /* should never happen after above revalidate */
+		printk(KERN_ERR "unionfs: lower dentry NULL\n");
 		err = -EINVAL;
 		goto out;
 	}
 	lower_inode = unionfs_lower_inode(inode);
 
+	/* give up if no lower_inode */
+	if(!lower_inode) {
+		printk(KERN_ERR "unionfs: lower inode NULL\n");
+		err = -EINVAL;
+		goto out;
+	}
 	/* check if user has permission to change lower inode */
 	err = inode_change_ok(lower_inode, ia);
 	if (err)
-- 
1.6.2.5

