OSDN Git Service

[DO NOT UPSTREAM] Skip creating subsystem/ in sysfs nodes
authorDaniel Leung <daniel.leung@intel.com>
Thu, 30 Aug 2012 20:06:16 +0000 (13:06 -0700)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Sat, 13 Dec 2014 17:06:39 +0000 (01:06 +0800)
Some not-so-well-designed Android apps try to recursively read
the sysfs nodes, e.g., cpu information. The subsystem/ node
sometimes is a symlink back to itself, and this causes these
apps to run out of memory iterating all the nodes.

This patch skips the creation of the subsystem nodes if it is
building for Android devices. There should not be any ill-effects
as Android userspace does not look at the subsystem nodes.

Issue: AXIA-629
Change-Id: I748c8b2fde85161e55b006319d46e8e6bbe4eb43
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
drivers/base/bus.c
drivers/base/core.c

index 83e910a..a0a5291 100644 (file)
@@ -518,10 +518,12 @@ int bus_add_device(struct device *dev)
                                                &dev->kobj, dev_name(dev));
                if (error)
                        goto out_id;
+#ifndef CONFIG_ANDROID
                error = sysfs_create_link(&dev->kobj,
                                &dev->bus->p->subsys.kobj, "subsystem");
                if (error)
                        goto out_subsys;
+#endif
                klist_add_tail(&dev->p->knode_bus, &bus->p->klist_devices);
        }
        return 0;
index 842d047..eb6f6df 100644 (file)
@@ -810,11 +810,13 @@ static int device_add_class_symlinks(struct device *dev)
        if (!dev->class)
                return 0;
 
+#ifndef CONFIG_ANDROID
        error = sysfs_create_link(&dev->kobj,
                                  &dev->class->p->subsys.kobj,
                                  "subsystem");
        if (error)
                goto out;
+#endif
 
        if (dev->parent && device_is_not_partition(dev)) {
                error = sysfs_create_link(&dev->kobj, &dev->parent->kobj,