lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Tue, 18 Dec 2012 02:13:04 +0100
From:	Hannes Frederic Sowa <hannes@...essinduktion.org>
To:	linux-kernel@...r.kernel.org
Cc:	npiggin@...nel.dk,
	Hannes Frederic Sowa <hannes@...essinduktion.org>
Subject: [PATCH v2 1/4] brd: change module parameters rd_size, rd_nr, max_part to unsigned

All parameters of the module brd are now converted to unsigneds. This
saves some less-than-zero checks. rd_size can now be static, because
the last external user in arch/arm/kernel/setup.c:setup_ramdisk is gone.

While at it, move the (perhaps automatically) placed brd_mutex out of
the silly constellation between function prelude comment and function
and convert simple

Cc: Nick Piggin <npiggin@...nel.dk>
Signed-off-by: Hannes Frederic Sowa <hannes@...essinduktion.org>
---
 drivers/block/brd.c | 45 ++++++++++++++++++++++-----------------------
 1 file changed, 22 insertions(+), 23 deletions(-)

diff --git a/drivers/block/brd.c b/drivers/block/brd.c
index 531ceb3..70ad8dc 100644
--- a/drivers/block/brd.c
+++ b/drivers/block/brd.c
@@ -48,10 +48,11 @@ struct brd_device {
 	struct radix_tree_root	brd_pages;
 };
 
+static DEFINE_MUTEX(brd_mutex);
+
 /*
  * Look up and return a brd's page for a given sector.
  */
-static DEFINE_MUTEX(brd_mutex);
 static struct page *brd_lookup_page(struct brd_device *brd, sector_t sector)
 {
 	pgoff_t idx;
@@ -429,15 +430,15 @@ static const struct block_device_operations brd_fops = {
 /*
  * And now the modules code and kernel interface.
  */
-static int rd_nr;
-int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
-static int max_part;
-static int part_shift;
-module_param(rd_nr, int, S_IRUGO);
+static unsigned int rd_nr;
+static unsigned int rd_size = CONFIG_BLK_DEV_RAM_SIZE;
+static unsigned int max_part;
+static unsigned int part_shift;
+module_param(rd_nr, uint, S_IRUGO);
 MODULE_PARM_DESC(rd_nr, "Maximum number of brd devices");
-module_param(rd_size, int, S_IRUGO);
+module_param(rd_size, uint, S_IRUGO);
 MODULE_PARM_DESC(rd_size, "Size of each RAM disk in kbytes.");
-module_param(max_part, int, S_IRUGO);
+module_param(max_part, uint, S_IRUGO);
 MODULE_PARM_DESC(max_part, "Maximum number of partitions per RAM disk");
 MODULE_LICENSE("GPL");
 MODULE_ALIAS_BLOCKDEV_MAJOR(RAMDISK_MAJOR);
@@ -447,7 +448,8 @@ MODULE_ALIAS("rd");
 /* Legacy boot options - nonmodular */
 static int __init ramdisk_size(char *str)
 {
-	rd_size = simple_strtol(str, NULL, 0);
+	if (kstrtoul(str, 0, &rd_size))
+		rd_size = 0;
 	return 1;
 }
 __setup("ramdisk_size=", ramdisk_size);
@@ -555,7 +557,7 @@ static struct kobject *brd_probe(dev_t dev, int *part, void *data)
 
 static int __init brd_init(void)
 {
-	int i, nr;
+	unsigned int i, nr;
 	unsigned long range;
 	struct brd_device *brd, *next;
 
@@ -574,20 +576,17 @@ static int __init brd_init(void)
 	 *     kernel automatically instantiate actual device on-demand.
 	 */
 
-	part_shift = 0;
-	if (max_part > 0) {
-		part_shift = fls(max_part);
+	part_shift = fls(max_part);
 
-		/*
-		 * Adjust max_part according to part_shift as it is exported
-		 * to user space so that user can decide correct minor number
-		 * if [s]he want to create more devices.
-		 *
-		 * Note that -1 is required because partition 0 is reserved
-		 * for the whole disk.
-		 */
-		max_part = (1UL << part_shift) - 1;
-	}
+	/*
+	 * Adjust max_part according to part_shift as it is exported
+	 * to user space so that user can decide correct minor number
+	 * if [s]he want to create more devices.
+	 *
+	 * Note that -1 is required because partition 0 is reserved
+	 * for the whole disk.
+	 */
+	max_part = (1UL << part_shift) - 1;
 
 	if ((1UL << part_shift) > DISK_MAX_PARTS)
 		return -EINVAL;
-- 
1.8.0.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists