Re: scsi_id segfault with udev-009

From: Daniel Stekloff
Date: Wed Dec 17 2003 - 13:19:29 EST


On Wednesday 17 December 2003 09:29 am, Martin Schlemmer wrote:
> Hi
>
> Getting this with scsi_id and udev-009:


Hi,

Scsi_id hasn't been changed to use the latest libsysfs changes. The
"directory" in the sysfs_class_device is now considered "private" and only
should be accessed using functions. Treating the structures as handles lets
us only load information when it's needed, reducing caching or stale
information and also helping performance.

Here's the problem.

static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
const char *attr)
{
return sysfs_get_value_from_attributes(dev->directory->attributes,
attr);
}

Please try this quick fix:

--- udev/extras/scsi_id/scsi_id.h 2003-12-08 01:42:46.000000000 -0800
+++ udev-fix/extras/scsi_id/scsi_id.h 2003-12-17 09:52:31.032184768 -0800
@@ -42,8 +42,14 @@
static inline char *sysfs_get_attr(struct sysfs_class_device *dev,
const char *attr)
{
- return sysfs_get_value_from_attributes(dev->directory->attributes,
- attr);
+ struct dlist *attributes = NULL;
+
+ attributes = sysfs_get_classdev_attributes(dev);
+
+ if (attributes == NULL)
+ return NULL;
+
+ return sysfs_get_value_from_attributes(attributes, attr);
}

extern int scsi_get_serial (struct sysfs_class_device *scsi_dev,
--- udev/extras/scsi_id/scsi_id.c 2003-12-08 01:42:46.000000000 -0800
+++ udev-fix/extras/scsi_id/scsi_id.c 2003-12-17 09:55:54.113311744 -0800
@@ -133,7 +133,7 @@
return -1;

snprintf(bus_dev_name, MAX_NAME_LEN, "%s/%s/%s/%s/%s", sysfs_mnt_path,
- SYSFS_BUS_DIR, bus, SYSFS_DEVICES_NAME, bus_id);
+ SYSFS_BUS_NAME, bus, SYSFS_DEVICES_NAME, bus_id);

if (stat(sysfs_path, &stat_buf))
return -1;

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