Re: 2.5.69-mm5: pccard oops while booting: resolved

Andrew Morton (akpm@digeo.com)
Thu, 15 May 2003 16:00:15 -0700


Felipe Alfaro Solana <felipe_alfaro@linuxmail.org> wrote:
>
> The test kernel is
> a 2.5.69-mm5 with the "i8259-shutdown.patch" reverted, plus the above
> patch and your previous "verbose" patch. Attached to this message is the
> new "dmesg" from this patched kernel.
>
> As I told Andrew, reverting "make-KOBJ_NAME-match-BUS_ID_SIZE.patch"
> solves the oops.

The weird thing is that this patch really doesn't do anything apart from
increasing KOBJ_NAME_LEN from 16 to 20.

From: Ben Collins <bcollins@debian.org>

This was causing me all sorts of problems with linux1394's 16-18 byte long
bus_id lengths. The sysfs names were all broken.

This not only makes KOBJ_NAME_LEN match BUS_ID_SIZE, but fixes the
strncpy's in drivers/base/ so that it can't happen again (at least the
strings will be null terminated).

drivers/base/bus.c | 2 ++
drivers/base/class.c | 2 ++
drivers/base/core.c | 1 +
include/linux/device.h | 2 +-
include/linux/kobject.h | 2 +-
5 files changed, 7 insertions(+), 2 deletions(-)

diff -puN drivers/base/bus.c~make-KOBJ_NAME-match-BUS_ID_SIZE drivers/base/bus.c
--- 25/drivers/base/bus.c~make-KOBJ_NAME-match-BUS_ID_SIZE 2003-05-14 19:18:09.000000000 -0700
+++ 25-akpm/drivers/base/bus.c 2003-05-14 19:18:09.000000000 -0700
@@ -432,6 +432,7 @@ int bus_add_driver(struct device_driver
pr_debug("bus %s: add driver %s\n",bus->name,drv->name);

strncpy(drv->kobj.name,drv->name,KOBJ_NAME_LEN);
+ drv->kobj.name[KOBJ_NAME_LEN-1] = '\0';
drv->kobj.kset = &bus->drivers;

if ((error = kobject_register(&drv->kobj))) {
@@ -541,6 +542,7 @@ struct bus_type * find_bus(char * name)
int bus_register(struct bus_type * bus)
{
strncpy(bus->subsys.kset.kobj.name,bus->name,KOBJ_NAME_LEN);
+ bus->subsys.kset.kobj.name[KOBJ_NAME_LEN-1] = '\0';
subsys_set_kset(bus,bus_subsys);
subsystem_register(&bus->subsys);

diff -puN drivers/base/class.c~make-KOBJ_NAME-match-BUS_ID_SIZE drivers/base/class.c
--- 25/drivers/base/class.c~make-KOBJ_NAME-match-BUS_ID_SIZE 2003-05-14 19:18:09.000000000 -0700
+++ 25-akpm/drivers/base/class.c 2003-05-14 19:18:09.000000000 -0700
@@ -89,6 +89,7 @@ int class_register(struct class * cls)
INIT_LIST_HEAD(&cls->interfaces);

strncpy(cls->subsys.kset.kobj.name,cls->name,KOBJ_NAME_LEN);
+ cls->subsys.kset.kobj.name[KOBJ_NAME_LEN-1] = '\0';
subsys_set_kset(cls,class_subsys);
subsystem_register(&cls->subsys);

@@ -259,6 +260,7 @@ int class_device_add(struct class_device

/* first, register with generic layer. */
strncpy(class_dev->kobj.name, class_dev->class_id, KOBJ_NAME_LEN);
+ class_dev->kobj.name[KOBJ_NAME_LEN-1] = '\0';
kobj_set_kset_s(class_dev, class_obj_subsys);
if (parent)
class_dev->kobj.parent = &parent->subsys.kset.kobj;
diff -puN drivers/base/core.c~make-KOBJ_NAME-match-BUS_ID_SIZE drivers/base/core.c
--- 25/drivers/base/core.c~make-KOBJ_NAME-match-BUS_ID_SIZE 2003-05-14 19:18:09.000000000 -0700
+++ 25-akpm/drivers/base/core.c 2003-05-14 19:18:09.000000000 -0700
@@ -214,6 +214,7 @@ int device_add(struct device *dev)

/* first, register with generic layer. */
strncpy(dev->kobj.name,dev->bus_id,KOBJ_NAME_LEN);
+ dev->kobj.name[KOBJ_NAME_LEN-1] = '\0';
kobj_set_kset_s(dev,devices_subsys);
if (parent)
dev->kobj.parent = &parent->kobj;
diff -puN include/linux/kobject.h~make-KOBJ_NAME-match-BUS_ID_SIZE include/linux/kobject.h
--- 25/include/linux/kobject.h~make-KOBJ_NAME-match-BUS_ID_SIZE 2003-05-14 19:18:09.000000000 -0700
+++ 25-akpm/include/linux/kobject.h 2003-05-14 19:18:09.000000000 -0700
@@ -12,7 +12,7 @@
#include <linux/rwsem.h>
#include <asm/atomic.h>

-#define KOBJ_NAME_LEN 16
+#define KOBJ_NAME_LEN 20

struct kobject {
char name[KOBJ_NAME_LEN];
diff -puN include/linux/device.h~make-KOBJ_NAME-match-BUS_ID_SIZE include/linux/device.h
--- 25/include/linux/device.h~make-KOBJ_NAME-match-BUS_ID_SIZE 2003-05-14 19:18:09.000000000 -0700
+++ 25-akpm/include/linux/device.h 2003-05-14 19:18:16.000000000 -0700
@@ -35,7 +35,7 @@
#define DEVICE_NAME_SIZE 50
#define DEVICE_NAME_HALF __stringify(20) /* Less than half to accommodate slop */
#define DEVICE_ID_SIZE 32
-#define BUS_ID_SIZE 20
+#define BUS_ID_SIZE KOBJ_NAME_LEN


enum {

_

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