summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormananth <mananth>2003-10-16 10:18:00 +0000
committermananth <mananth>2003-10-16 10:18:00 +0000
commit4da45e83502c76a53faebe3fb5d0bac72e868dee (patch)
tree20aea3eab0ce0071c654c20d1aa87dd1484423ec
parent0bf875d60a04177ca28aaa6b87de69a96a0b5ef9 (diff)
downloadsysfsutils-4da45e83502c76a53faebe3fb5d0bac72e868dee.tar.gz
Fix segfault in sysfs_block.c while displaying initrd device and a possible
bug in systool.c
-rw-r--r--ChangeLog4
-rw-r--r--cmd/systool.c2
-rw-r--r--lib/sysfs_block.c12
3 files changed, 17 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 20b82d5..6ca7392 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
10/15/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
+ * Fixed bug in sysfs_block.c (initrd)
+ * Fixed possible bug in systool.c
+
+10/15/2003 - Ananth Mavinakayanahalli <ananth@in.ibm.com>
* Changed get_devices_list to get_bus_devices_list
* Fixed usage messages in tests
diff --git a/cmd/systool.c b/cmd/systool.c
index aa36439..b6e1b78 100644
--- a/cmd/systool.c
+++ b/cmd/systool.c
@@ -512,7 +512,7 @@ int show_sysfs_root(unsigned char *rootname)
fprintf(stdout, "Root Device Tree: %s\n", rootname);
- if (root->devices) {
+ if (root->devices != NULL) {
dlist_for_each_data(root->devices, device,
struct sysfs_device) {
show_device_tree(device, 2);
diff --git a/lib/sysfs_block.c b/lib/sysfs_block.c
index 60a3949..6a9c97c 100644
--- a/lib/sysfs_block.c
+++ b/lib/sysfs_block.c
@@ -127,6 +127,8 @@ static int get_all_block_devices(struct sysfs_block_device *block)
errno = EINVAL;
return -1;
}
+ if (block->directory->subdirs == NULL)
+ return 0;
dlist_for_each_data(block->directory->subdirs, cur,
struct sysfs_directory) {
@@ -270,6 +272,9 @@ struct dlist *sysfs_get_queue_attributes(struct sysfs_block_device *block)
{
struct sysfs_directory *dir = NULL;
+ if (block->directory->subdirs == NULL)
+ return NULL;
+
dlist_for_each_data(block->directory->subdirs, dir,
struct sysfs_directory) {
if ((strcmp(dir->name, SYSFS_QUEUE_NAME)) != 0)
@@ -292,6 +297,9 @@ struct dlist *sysfs_get_iosched_attributes(struct sysfs_block_device *block)
struct sysfs_directory *dir = NULL, *new = NULL;
unsigned int found = 0;
+ if (block->directory->subdirs == NULL)
+ return NULL;
+
dlist_for_each_data(block->directory->subdirs, dir,
struct sysfs_directory) {
if ((strcmp(dir->name, SYSFS_QUEUE_NAME)) != 0)
@@ -306,6 +314,9 @@ struct dlist *sysfs_get_iosched_attributes(struct sysfs_block_device *block)
* this is the queue directory - read this and the
* iosched directory too
*/
+ if (dir->subdirs == NULL)
+ goto noiosched;
+
dlist_for_each_data(dir->subdirs, new,
struct sysfs_directory) {
if ((strcmp(new->name, SYSFS_IOSCHED_NAME)) == 0)
@@ -313,6 +324,7 @@ struct dlist *sysfs_get_iosched_attributes(struct sysfs_block_device *block)
return new->attributes;
}
}
+noiosched:
dprintf("IOSCHED attributes not found\n");
return NULL;
}