# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
#	           ChangeSet	1.600.1.11 -> 1.600.1.12
#	drivers/usb/core/inode.c	1.39    -> 1.40   
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/09/04	greg@kroah.com	1.600.1.12
# USB: clean up the error path in create_special_files() for usbfs
# 
# Thanks to David Brownell for pointing out the problem here.
# --------------------------------------------
#
diff -Nru a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
--- a/drivers/usb/core/inode.c	Thu Sep  5 08:51:04 2002
+++ b/drivers/usb/core/inode.c	Thu Sep  5 08:51:04 2002
@@ -560,35 +560,57 @@
 static int create_special_files (void)
 {
 	struct dentry *parent;
-	int retval;
+	int retval = 0;
 
 	/* create the devices special file */
 	retval = get_mount (&usbdevice_fs_type, &usbdevfs_mount);
-	if (retval)
-		return retval;
+	if (retval) {
+		err ("Unable to get usbdevfs mount");
+		goto exit;
+	}
+
 	retval = get_mount (&usb_fs_type, &usbfs_mount);
 	if (retval) {
-		put_mount (&usbfs_mount);
-		return retval;
+		err ("Unable to get usbfs mount");
+		goto error_clean_usbdevfs_mount;
 	}
+
 	parent = usbfs_mount->mnt_sb->s_root;
-	devices_usbfs_dentry = fs_create_file ("devices", listmode | S_IFREG, parent,
+	devices_usbfs_dentry = fs_create_file ("devices",
+					       listmode | S_IFREG, parent,
 					       NULL, &usbdevfs_devices_fops,
 					       listuid, listgid);
 	if (devices_usbfs_dentry == NULL) {
 		err ("Unable to create devices usbfs file");
-		return -ENODEV;
+		retval = -ENODEV;
+		goto error_clean_mounts;
 	}
+
 	parent = usbdevfs_mount->mnt_sb->s_root;
-	devices_usbdevfs_dentry = fs_create_file ("devices", listmode | S_IFREG, parent,
+	devices_usbdevfs_dentry = fs_create_file ("devices",
+						  listmode | S_IFREG, parent,
 						  NULL, &usbdevfs_devices_fops,
 						  listuid, listgid);
 	if (devices_usbdevfs_dentry == NULL) {
 		err ("Unable to create devices usbfs file");
-		return -ENODEV;
+		retval = -ENODEV;
+		goto error_remove_file;
 	}
 
-	return 0;
+	goto exit;
+	
+error_remove_file:
+	fs_remove_file (devices_usbfs_dentry);
+	devices_usbfs_dentry = NULL;
+
+error_clean_mounts:
+	put_mount (&usbfs_mount);
+
+error_clean_usbdevfs_mount:
+	put_mount (&usbdevfs_mount);	
+
+exit:
+	return retval;
 }
 
 static void remove_special_files (void)
