public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tmpfs 1/4 symlink unwind
@ 2002-06-12  2:51 Hugh Dickins
  2002-06-12  2:54 ` [PATCH] tmpfs 2/4 mknod times Hugh Dickins
  0 siblings, 1 reply; 3+ messages in thread
From: Hugh Dickins @ 2002-06-12  2:51 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: Alan Cox, Christoph Rohland, linux-kernel

shmem_symlink error path forgot to unwind.  The failed symlink left
over could be unlinked, but long ones were left on the shmem_inodes
list, causing oops in swapoff at shutdown if not earlier.

--- 2.4.19-pre10/mm/shmem.c	Tue Jun  4 13:54:20 2002
+++ linux/mm/shmem.c	Tue Jun 11 19:02:30 2002
@@ -1123,17 +1123,20 @@
 		return error;
 
 	len = strlen(symname) + 1;
-	if (len > PAGE_CACHE_SIZE)
-		return -ENAMETOOLONG;
-		
 	inode = dentry->d_inode;
 	info = SHMEM_I(inode);
 	inode->i_size = len-1;
+	inode->i_op = &shmem_symlink_inline_operations;
+
 	if (len <= sizeof(struct shmem_inode_info)) {
 		/* do it inline */
 		memcpy(info, symname, len);
-		inode->i_op = &shmem_symlink_inline_operations;
 	} else {
+		if (len > PAGE_CACHE_SIZE) {
+			error = -ENAMETOOLONG;
+			goto rmnod;
+		}
+		inode->i_op = &shmem_symlink_inode_operations;
 		spin_lock (&shmem_ilock);
 		list_add (&info->list, &shmem_inodes);
 		spin_unlock (&shmem_ilock);
@@ -1141,7 +1144,8 @@
 		page = shmem_getpage_locked(info, inode, 0);
 		if (IS_ERR(page)) {
 			up(&info->sem);
-			return PTR_ERR(page);
+			error = PTR_ERR(page);
+			goto rmnod;
 		}
 		kaddr = kmap(page);
 		memcpy(kaddr, symname, len);
@@ -1150,10 +1154,14 @@
 		UnlockPage(page);
 		page_cache_release(page);
 		up(&info->sem);
-		inode->i_op = &shmem_symlink_inode_operations;
 	}
 	dir->i_ctime = dir->i_mtime = CURRENT_TIME;
 	return 0;
+
+rmnod:
+	if (!shmem_unlink(dir, dentry))
+		d_delete(dentry);
+	return error;
 }
 
 static int shmem_readlink_inline(struct dentry *dentry, char *buffer, int buflen)


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-06-12 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Pine.LNX.4.21.0206120423200.1290-100000@localhost.localdomain>
2002-06-12  3:31 ` [PATCH] tmpfs 2/4 mknod times Ryan Cumming
2002-06-12 15:26   ` Jan Harkes
2002-06-12  2:51 [PATCH] tmpfs 1/4 symlink unwind Hugh Dickins
2002-06-12  2:54 ` [PATCH] tmpfs 2/4 mknod times Hugh Dickins

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox