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]
Message-Id: <20200325154843.1349040-10-hch@lst.de>
Date:   Wed, 25 Mar 2020 16:48:43 +0100
From:   Christoph Hellwig <hch@....de>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 9/9] block: make the init_part_stats return value more logical

Return 0 / -ENOMEM instead of a boolean dressed up as int.

Signed-off-by: Christoph Hellwig <hch@....de>
---
 block/genhd.c             | 2 +-
 block/partitions/core.c   | 2 +-
 include/linux/part_stat.h | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/block/genhd.c b/block/genhd.c
index 6323cc789efa..95aef19ca8ed 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -1644,7 +1644,7 @@ struct gendisk *__alloc_disk_node(int minors, int node_id)
 
 	disk = kzalloc_node(sizeof(struct gendisk), GFP_KERNEL, node_id);
 	if (disk) {
-		if (!init_part_stats(&disk->part0)) {
+		if (init_part_stats(&disk->part0)) {
 			kfree(disk);
 			return NULL;
 		}
diff --git a/block/partitions/core.c b/block/partitions/core.c
index b79c4513629b..6509351cb9d3 100644
--- a/block/partitions/core.c
+++ b/block/partitions/core.c
@@ -377,7 +377,7 @@ struct hd_struct *add_partition(struct gendisk *disk, int partno,
 	if (!p)
 		return ERR_PTR(-EBUSY);
 
-	if (!init_part_stats(p)) {
+	if (init_part_stats(p)) {
 		err = -ENOMEM;
 		goto out_free;
 	}
diff --git a/include/linux/part_stat.h b/include/linux/part_stat.h
index ece607607a86..521ad787b0ec 100644
--- a/include/linux/part_stat.h
+++ b/include/linux/part_stat.h
@@ -48,8 +48,8 @@ static inline int init_part_stats(struct hd_struct *part)
 {
 	part->dkstats = alloc_percpu(struct disk_stats);
 	if (!part->dkstats)
-		return 0;
-	return 1;
+		return -ENOMEM;
+	return 0;
 }
 
 static inline void free_part_stats(struct hd_struct *part)
@@ -72,7 +72,7 @@ static inline void part_stat_set_all(struct hd_struct *part, int value)
 
 static inline int init_part_stats(struct hd_struct *part)
 {
-	return 1;
+	return 0;
 }
 
 static inline void free_part_stats(struct hd_struct *part)
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ