Skip to contentSkip to conversation

fix disk_part_tbl always alloced in node 0: set node_id before refered in alloc_disk

PATCH In review [email protected] 2 participants 2 messages Nov 19, 2008 – Nov 20, 2008 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix disk_part_tbl always alloced in node 0: set node_id before refered in alloc_disk

From: Cheng Renquan <[email protected]>

disk->node_id will be refered in allocating in disk_expand_part_tbl, so we should set it before disk->node_id is refered.

---
 block/genhd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
block/genhd.c +1 -1
index 27549e4..2f7feda 100644
@@ -1102,6 +1102,7 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 			kfree(disk);
 			return NULL;
 		}
+		disk->node_id = node_id;
 		if (disk_expand_part_tbl(disk, 0)) {
 			free_part_stats(&disk->part0);
 			kfree(disk);
@@ -1116,7 +1117,6 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 		device_initialize(disk_to_dev(disk));
 		INIT_WORK(&disk->async_notify,
 			media_change_notify_thread);
-		disk->node_id = node_id;
 	}
 	return disk;
 }
Signature · 1 line
1.6.0.4.758.g36c05
#1 lore raw
Quoted 23 lines · On Thu, Nov 20 2008, [email protected] wrote:

From: Cheng Renquan <[email protected]>

disk->node_id will be refered in allocating in disk_expand_part_tbl, so we should set it before disk->node_id is refered.

---
 block/genhd.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
block/genhd.c +1 -0
index 27549e4..2f7feda 100644
@@ -1102,6 +1102,7 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 			kfree(disk);
 			return NULL;
 		}
+		disk->node_id = node_id;
 		if (disk_expand_part_tbl(disk, 0)) {
 			free_part_stats(&disk->part0);
 			kfree(disk);

block/genhd.c struct gendisk *alloc_disk_node(int minors, int node_id) · line 1122

Quoted 7 lines
block/genhd.c +0 -1
@@ -1116,7 +1117,6 @@ struct gendisk *alloc_disk_node(int minors, int node_id)
 		device_initialize(disk_to_dev(disk));
 		INIT_WORK(&disk->async_notify,
 			media_change_notify_thread);
-		disk->node_id = node_id;
 	}
 	return disk;
 }

Good spotting, applied!

Signature · 1 line
Jens Axboe