From baf6c7143a8c2361648b4d68da92a8a11002c06d Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Thu, 27 Dec 2007 15:35:04 +0000 Subject: [PATCH] Don't choke on unrecognized devices (#2087). git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5086 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + lib/sysfs.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 7a6c3314..e899cab6 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,7 @@ lm_sensors CHANGES file SVN-HEAD Library: Fix fschrc and fschmd support Fix sysfs presence detection + Don't choke on unrecognized devices (#2087) Makefile: Revert changeset 4738, fix bug #2187 differently Module adm1026: Various cleanups Module eeprom: Hide Sony Vaio serial numbers to regular users (2.6 backport) diff --git a/lib/sysfs.c b/lib/sysfs.c index 8e162376..2adcf8cb 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -60,6 +60,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) struct sysfs_attribute *attr, *bus_attr; char bus_path[SYSFS_PATH_MAX]; sensors_proc_chips_entry entry; + int err = -SENSORS_ERR_PARSE; /* ignore any device without name attribute */ if (!(attr = sysfs_get_device_attr(dev, "name"))) @@ -112,8 +113,11 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) /* PCI */ entry.name.addr = (domain << 16) + (bus << 8) + (slot << 3) + fn; entry.name.bus = SENSORS_CHIP_NAME_BUS_PCI; - } else + } else { + /* Ignore unknown devices */ + err = 0; goto exit_free; + } sensors_add_proc_chips(&entry); @@ -122,7 +126,7 @@ static int sensors_read_one_sysfs_chip(struct sysfs_device *dev) exit_free: free(entry.name.prefix); free(entry.name.busname); - return -SENSORS_ERR_PARSE; + return err; } /* returns 0 if successful, !0 otherwise */