Skip to contentSkip to conversation

2.4.13pre3: loop uses wrong type for blk_size[]

PATCH New Chip Salzenberg 1 participant 1 message Oct 17, 2001 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.13pre3: loop uses wrong type for blk_size[]

In 2.4.13pre3, the loop device was changed to use an array of unsigned long for its entry in blk_size[]. This is broken, because blk_size[] is of type 'int * []'. A patch is attached which fixes this problem while still retaining the presumably intended behavior of working properly with large devices.

Signature · 2 lines
Chip Salzenberg               - a.k.a. -              <[email protected]>
 "We have no fuel on board, plus or minus 8 kilograms."  -- NEAR tech

Index: linux/drivers/block/loop.c

drivers/block/loop.c renamed from drivers/block/loop.c.old +5 -5
@@ -78,5 +78,5 @@
 static int max_loop = 8;
 static struct loop_device *loop_dev;
-static unsigned long *loop_sizes;
+static int *loop_sizes;
 static int *loop_blksizes;
 static devfs_handle_t devfs_handle;      /*  For the directory */
@@ -152,5 +152,5 @@
 #define MAX_DISK_SIZE 1024*1024*1024
 
-static unsigned long compute_loop_size(struct loop_device *lo, struct dentry * lo_dentry, kdev_t lodev)
+static int compute_loop_size(struct loop_device *lo, struct dentry * lo_dentry, kdev_t lodev)
 {
 	if (S_ISREG(lo_dentry->d_inode->i_mode))
@@ -877,5 +877,5 @@
 			break;
 		}
-		err = put_user(loop_sizes[lo->lo_number] << 1, (unsigned long *) arg);
+		err = put_user((unsigned long)loop_sizes[lo->lo_number] << 1, (unsigned long *) arg);
 		break;
 	case BLKGETSIZE64:
@@ -1019,5 +1019,5 @@
 		return -ENOMEM;
 
-	loop_sizes = kmalloc(max_loop * sizeof(unsigned long), GFP_KERNEL);
+	loop_sizes = kmalloc(max_loop * sizeof(int), GFP_KERNEL);
 	if (!loop_sizes)
 		goto out_sizes;
@@ -1039,5 +1039,5 @@
 	}
 
-	memset(loop_sizes, 0, max_loop * sizeof(unsigned long));
+	memset(loop_sizes, 0, max_loop * sizeof(int));
 	memset(loop_blksizes, 0, max_loop * sizeof(int));
 	blk_size[MAJOR_NR] = loop_sizes;