From da4759c73b0f1aac79f37bdb39ad2124439c30e7 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 12 Mar 2015 09:58:26 -0400 Subject: sysfs: Use only return value from is_visible for the file mode Up to now, is_visible can only be used to either remove visibility of a file entirely or to add permissions, but not to reduce permissions. This makes it impossible, for example, to use DEVICE_ATTR_RW to define file attributes and reduce permissions to read-only. This behavior is undesirable and unnecessarily complicates code which needs to reduce permissions; instead of just returning the desired permissions, it has to ensure that the permissions in the attribute variable declaration only reflect the minimal permissions ever needed. Change semantics of is_visible to only use the permissions returned from it instead of oring the returned value with the hard-coded permissions. Signed-off-by: Guenter Roeck Signed-off-by: Vivien Didelot Signed-off-by: Greg Kroah-Hartman diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 2554d88..3fdccd9 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -41,7 +41,7 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj, if (grp->attrs) { for (i = 0, attr = grp->attrs; *attr && !error; i++, attr++) { - umode_t mode = 0; + umode_t mode = (*attr)->mode; /* * In update mode, we're changing the permissions or @@ -56,8 +56,7 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj, continue; } error = sysfs_add_file_mode_ns(parent, *attr, false, - (*attr)->mode | mode, - NULL); + mode, NULL); if (unlikely(error)) break; } -- cgit v0.10.2 From d8bf8c92e80fed9119eb222c7e5cc88acf57c12c Mon Sep 17 00:00:00 2001 From: Vivien Didelot Date: Thu, 12 Mar 2015 09:58:27 -0400 Subject: sysfs: Only accept read/write permissions for file attributes For sysfs file attributes, only read and write permissions make sense. Mask provided attribute permissions accordingly and send a warning to the console if invalid permission bits are set. This patch is originally from Guenter [1] and includes the fixup explained in the thread, that is printing permissions in octal format and limiting the scope of attributes to SYSFS_PREALLOC | 0664. [1] https://lkml.org/lkml/2015/1/19/599 Signed-off-by: Vivien Didelot Reviewed-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c index 3fdccd9..b400c04 100644 --- a/fs/sysfs/group.c +++ b/fs/sysfs/group.c @@ -55,6 +55,12 @@ static int create_files(struct kernfs_node *parent, struct kobject *kobj, if (!mode) continue; } + + WARN(mode & ~(SYSFS_PREALLOC | 0664), + "Attribute %s: Invalid permissions 0%o\n", + (*attr)->name, mode); + + mode &= SYSFS_PREALLOC | 0664; error = sysfs_add_file_mode_ns(parent, *attr, false, mode, NULL); if (unlikely(error)) -- cgit v0.10.2 From ba61af6f3e4766c76aec0b5e7f2bb8277e1acdd0 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Thu, 12 Mar 2015 09:58:28 -0400 Subject: sysfs: Document struct attribute_group Document variables defined in struct attribute_group to ensure correct usage. Signed-off-by: Guenter Roeck Signed-off-by: Vivien Didelot Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h index ddad161..99382c0 100644 --- a/include/linux/sysfs.h +++ b/include/linux/sysfs.h @@ -57,6 +57,21 @@ do { \ #define sysfs_attr_init(attr) do {} while (0) #endif +/** + * struct attribute_group - data structure used to declare an attribute group. + * @name: Optional: Attribute group name + * If specified, the attribute group will be created in + * a new subdirectory with this name. + * @is_visible: Optional: Function to return permissions associated with an + * attribute of the group. Will be called repeatedly for each + * attribute in the group. Only read/write permissions as well as + * SYSFS_PREALLOC are accepted. Must return 0 if an attribute is + * not visible. The returned value will replace static permissions + * defined in struct attribute or struct bin_attribute. + * @attrs: Pointer to NULL terminated list of attributes. + * @bin_attrs: Pointer to NULL terminated list of binary attributes. + * Either attrs or bin_attrs or both must be provided. + */ struct attribute_group { const char *name; umode_t (*is_visible)(struct kobject *, -- cgit v0.10.2 From bb2b40754ff4b2fffd8015ac96c45269cb54ee79 Mon Sep 17 00:00:00 2001 From: Sergei Shtylyov Date: Sat, 17 Jan 2015 22:14:41 +0300 Subject: driver core: use *switch* statement in really_probe() There are series of comparisons of the 'ret' variable on the failure path of really_probe(), so the *switch* statement seems more appropriate there. Signed-off-by: Sergei Shtylyov Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/dd.c b/drivers/base/dd.c index cdc779c..bfece0c 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -320,21 +320,25 @@ probe_failed: dev->driver = NULL; dev_set_drvdata(dev, NULL); - if (ret == -EPROBE_DEFER) { + switch (ret) { + case -EPROBE_DEFER: /* Driver requested deferred probing */ dev_info(dev, "Driver %s requests probe deferral\n", drv->name); driver_deferred_probe_add(dev); /* Did a trigger occur while probing? Need to re-trigger if yes */ if (local_trigger_count != atomic_read(&deferred_trigger_count)) driver_deferred_probe_trigger(); - } else if (ret != -ENODEV && ret != -ENXIO) { + break; + case -ENODEV: + case -ENXIO: + pr_debug("%s: probe of %s rejects match %d\n", + drv->name, dev_name(dev), ret); + break; + default: /* driver matched but the probe failed */ printk(KERN_WARNING "%s: probe of %s failed with error %d\n", drv->name, dev_name(dev), ret); - } else { - pr_debug("%s: probe of %s rejects match %d\n", - drv->name, dev_name(dev), ret); } /* * Ignore errors returned by ->probe so that the next driver can try -- cgit v0.10.2 From 1c34203a1496d1849ba978021b878b3447d433c8 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Wed, 28 Jan 2015 10:02:44 +0800 Subject: driver core: bus: Goto appropriate labels on failure in bus_add_device It is not necessary to call device_remove_groups() when device_add_groups() fails. The group added by device_add_groups() should be removed if sysfs_create_link() fails. Fixes: fa6fdb33b486 ("driver core: bus_type: add dev_groups") Signed-off-by: Junjie Mao Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/bus.c b/drivers/base/bus.c index 876bae5..79bc203 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -515,11 +515,11 @@ int bus_add_device(struct device *dev) goto out_put; error = device_add_groups(dev, bus->dev_groups); if (error) - goto out_groups; + goto out_id; error = sysfs_create_link(&bus->p->devices_kset->kobj, &dev->kobj, dev_name(dev)); if (error) - goto out_id; + goto out_groups; error = sysfs_create_link(&dev->kobj, &dev->bus->p->subsys.kobj, "subsystem"); if (error) -- cgit v0.10.2 From 5fd637e7a75fb2a4c0b62683c08dae959160fedf Mon Sep 17 00:00:00 2001 From: Rastislav Barlik Date: Wed, 17 Dec 2014 21:14:48 +0100 Subject: samples/kobject: Use kstrtoint instead of sscanf Use kstrtoint function instead of sscanf and check for return values. Signed-off-by: Rastislav Barlik Signed-off-by: Greg Kroah-Hartman diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c index 01562e0..063aaec 100644 --- a/samples/kobject/kobject-example.c +++ b/samples/kobject/kobject-example.c @@ -36,7 +36,12 @@ static ssize_t foo_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t foo_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%du", &foo); + int ret; + + ret = kstrtoint(buf, 10, &foo); + if (ret < 0) + return ret; + return count; } @@ -63,9 +68,12 @@ static ssize_t b_show(struct kobject *kobj, struct kobj_attribute *attr, static ssize_t b_store(struct kobject *kobj, struct kobj_attribute *attr, const char *buf, size_t count) { - int var; + int var, ret; + + ret = kstrtoint(buf, 10, &var); + if (ret < 0) + return ret; - sscanf(buf, "%du", &var); if (strcmp(attr->attr.name, "baz") == 0) baz = var; else diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index ab5e447..e80ced3 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c @@ -120,7 +120,12 @@ static ssize_t foo_show(struct foo_obj *foo_obj, struct foo_attribute *attr, static ssize_t foo_store(struct foo_obj *foo_obj, struct foo_attribute *attr, const char *buf, size_t count) { - sscanf(buf, "%du", &foo_obj->foo); + int ret; + + ret = kstrtoint(buf, 10, &foo_obj->foo); + if (ret < 0) + return ret; + return count; } @@ -147,9 +152,12 @@ static ssize_t b_show(struct foo_obj *foo_obj, struct foo_attribute *attr, static ssize_t b_store(struct foo_obj *foo_obj, struct foo_attribute *attr, const char *buf, size_t count) { - int var; + int var, ret; + + ret = kstrtoint(buf, 10, &var); + if (ret < 0) + return ret; - sscanf(buf, "%du", &var); if (strcmp(attr->attr.name, "baz") == 0) foo_obj->baz = var; else -- cgit v0.10.2 From 07afb6ace3bde4ffdce26befa6b2f38c5d708dd0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 25 Mar 2015 13:41:42 +0100 Subject: samples/kobject: be explicit in the module license Rusty pointed out that the module license should be "GPL v2" to properly match the notice at the top of the files, so make that change. Reported-by: Rusty Russell Signed-off-by: Greg Kroah-Hartman diff --git a/samples/kobject/kobject-example.c b/samples/kobject/kobject-example.c index 063aaec..2e0740f 100644 --- a/samples/kobject/kobject-example.c +++ b/samples/kobject/kobject-example.c @@ -142,5 +142,5 @@ static void __exit example_exit(void) module_init(example_init); module_exit(example_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Greg Kroah-Hartman "); diff --git a/samples/kobject/kset-example.c b/samples/kobject/kset-example.c index e80ced3..a55bff5 100644 --- a/samples/kobject/kset-example.c +++ b/samples/kobject/kset-example.c @@ -285,5 +285,5 @@ static void __exit example_exit(void) module_init(example_init); module_exit(example_exit); -MODULE_LICENSE("GPL"); +MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Greg Kroah-Hartman "); -- cgit v0.10.2 From 3c9b8aaf95bb4de3d8ac9fd83d4aca2c97bd9f2a Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Thu, 29 Jan 2015 12:29:22 +0100 Subject: drivers/base/node: Avoid manual device_create_file() calls Instead of manual calls of multiple device_create_file() and device_remove_file(), use the static attribute groups assigned to the new device. This also fixes the possible races, too. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/node.c b/drivers/base/node.c index 36fabe43..06dce51 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -200,6 +200,25 @@ static ssize_t node_read_distance(struct device *dev, } static DEVICE_ATTR(distance, S_IRUGO, node_read_distance, NULL); +static struct attribute *node_dev_attrs[] = { + &dev_attr_cpumap.attr, + &dev_attr_cpulist.attr, + &dev_attr_meminfo.attr, + &dev_attr_numastat.attr, + &dev_attr_distance.attr, + &dev_attr_vmstat.attr, + NULL +}; + +static struct attribute_group node_dev_attr_group = { + .attrs = node_dev_attrs, +}; + +static const struct attribute_group *node_dev_attr_groups[] = { + &node_dev_attr_group, + NULL +}; + #ifdef CONFIG_HUGETLBFS /* * hugetlbfs per node attributes registration interface: @@ -273,16 +292,10 @@ static int register_node(struct node *node, int num, struct node *parent) node->dev.id = num; node->dev.bus = &node_subsys; node->dev.release = node_device_release; + node->dev.groups = node_dev_attr_groups; error = device_register(&node->dev); if (!error){ - device_create_file(&node->dev, &dev_attr_cpumap); - device_create_file(&node->dev, &dev_attr_cpulist); - device_create_file(&node->dev, &dev_attr_meminfo); - device_create_file(&node->dev, &dev_attr_numastat); - device_create_file(&node->dev, &dev_attr_distance); - device_create_file(&node->dev, &dev_attr_vmstat); - hugetlb_register_node(node); compaction_register_node(node); @@ -299,13 +312,6 @@ static int register_node(struct node *node, int num, struct node *parent) */ void unregister_node(struct node *node) { - device_remove_file(&node->dev, &dev_attr_cpumap); - device_remove_file(&node->dev, &dev_attr_cpulist); - device_remove_file(&node->dev, &dev_attr_meminfo); - device_remove_file(&node->dev, &dev_attr_numastat); - device_remove_file(&node->dev, &dev_attr_distance); - device_remove_file(&node->dev, &dev_attr_vmstat); - hugetlb_unregister_node(node); /* no-op, if memoryless node */ device_unregister(&node->dev); -- cgit v0.10.2 From 7ca7ec40f42a13c6966fb3a5d8713e895d58c728 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 25 Mar 2015 13:47:17 +0100 Subject: drivers/base/node: clean up attribute group conversion We can use the ATTRIBUTE_GROUPS() macro here, so use it, saving some lines of code. Cc: Takashi Iwai Signed-off-by: Greg Kroah-Hartman gregkh@linuxfoundation.org diff --git a/drivers/base/node.c b/drivers/base/node.c index 06dce51..6356866 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -209,15 +209,7 @@ static struct attribute *node_dev_attrs[] = { &dev_attr_vmstat.attr, NULL }; - -static struct attribute_group node_dev_attr_group = { - .attrs = node_dev_attrs, -}; - -static const struct attribute_group *node_dev_attr_groups[] = { - &node_dev_attr_group, - NULL -}; +ATTRIBUTE_GROUPS(node_dev); #ifdef CONFIG_HUGETLBFS /* @@ -292,7 +284,7 @@ static int register_node(struct node *node, int num, struct node *parent) node->dev.id = num; node->dev.bus = &node_subsys; node->dev.release = node_device_release; - node->dev.groups = node_dev_attr_groups; + node->dev.groups = node_dev_groups; error = device_register(&node->dev); if (!error){ -- cgit v0.10.2 From 5f0163a5ee9cc7c59751768bdfd94a73186debba Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Thu, 5 Feb 2015 11:48:26 +0100 Subject: driver core: Delete an unnecessary check before the function call "put_device" The put_device() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/core.c b/drivers/base/core.c index 07304a3..e0998b6 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -1095,8 +1095,7 @@ done: kobject_del(&dev->kobj); Error: cleanup_device_parent(dev); - if (parent) - put_device(parent); + put_device(parent); name_error: kfree(dev->p); dev->p = NULL; -- cgit v0.10.2 From 7036cd46c8239a520abf69720de9a8538a9011d5 Mon Sep 17 00:00:00 2001 From: Florin Papa Date: Sun, 8 Mar 2015 12:24:05 +0200 Subject: Driver core: Fix missing whitespace in function argument Found this using checkpatch.pl. Signed-off-by: Florin Papa Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/property.c b/drivers/base/property.c index c458458..423df59 100644 --- a/drivers/base/property.c +++ b/drivers/base/property.c @@ -365,7 +365,7 @@ int fwnode_property_read_string(struct fwnode_handle *fwnode, const char *propname, const char **val) { if (is_of_node(fwnode)) - return of_property_read_string(of_node(fwnode),propname, val); + return of_property_read_string(of_node(fwnode), propname, val); else if (is_acpi_node(fwnode)) return acpi_dev_prop_read(acpi_node(fwnode), propname, DEV_PROP_STRING, val, 1); -- cgit v0.10.2 From 2e4fabec5e79d9fb8b75e4afda192ed3d6486f86 Mon Sep 17 00:00:00 2001 From: Andrei Poenaru Date: Sun, 8 Mar 2015 12:29:02 +0200 Subject: drivers: base: map: Use kmalloc_array instead of kmalloc Reported by checkpatch.pl While at it, removed blank line between function call and error checking. Signed-off-by: Andrei Poenaru Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/map.c b/drivers/base/map.c index e87017f..c1d3823 100644 --- a/drivers/base/map.c +++ b/drivers/base/map.c @@ -41,8 +41,7 @@ int kobj_map(struct kobj_map *domain, dev_t dev, unsigned long range, if (n > 255) n = 255; - p = kmalloc(sizeof(struct probe) * n, GFP_KERNEL); - + p = kmalloc_array(n, sizeof(struct probe), GFP_KERNEL); if (p == NULL) return -ENOMEM; -- cgit v0.10.2 From 3d3af6afa9985ca30d9ee8f48897eb71f9c1583f Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Sun, 8 Mar 2015 12:29:04 +0200 Subject: drivers: base: memory: Fix switch indent Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 85be040..eb461cf 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -152,20 +152,20 @@ static ssize_t show_mem_state(struct device *dev, * so that they're not open-coded */ switch (mem->state) { - case MEM_ONLINE: - len = sprintf(buf, "online\n"); - break; - case MEM_OFFLINE: - len = sprintf(buf, "offline\n"); - break; - case MEM_GOING_OFFLINE: - len = sprintf(buf, "going-offline\n"); - break; - default: - len = sprintf(buf, "ERROR-UNKNOWN-%ld\n", - mem->state); - WARN_ON(1); - break; + case MEM_ONLINE: + len = sprintf(buf, "online\n"); + break; + case MEM_OFFLINE: + len = sprintf(buf, "offline\n"); + break; + case MEM_GOING_OFFLINE: + len = sprintf(buf, "going-offline\n"); + break; + default: + len = sprintf(buf, "ERROR-UNKNOWN-%ld\n", + mem->state); + WARN_ON(1); + break; } return len; @@ -232,19 +232,19 @@ memory_block_action(unsigned long phys_index, unsigned long action, int online_t first_page = pfn_to_page(start_pfn); switch (action) { - case MEM_ONLINE: - if (!pages_correctly_reserved(start_pfn)) - return -EBUSY; - - ret = online_pages(start_pfn, nr_pages, online_type); - break; - case MEM_OFFLINE: - ret = offline_pages(start_pfn, nr_pages); - break; - default: - WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " - "%ld\n", __func__, phys_index, action, action); - ret = -EINVAL; + case MEM_ONLINE: + if (!pages_correctly_reserved(start_pfn)) + return -EBUSY; + + ret = online_pages(start_pfn, nr_pages, online_type); + break; + case MEM_OFFLINE: + ret = offline_pages(start_pfn, nr_pages); + break; + default: + WARN(1, KERN_WARNING "%s(%ld, %ld) unknown action: " + "%ld\n", __func__, phys_index, action, action); + ret = -EINVAL; } return ret; -- cgit v0.10.2 From 481026dbe88bd42cae88ade3289f26d16e5168aa Mon Sep 17 00:00:00 2001 From: Cosmin Dragomir Date: Sun, 8 Mar 2015 12:30:14 +0200 Subject: attribute_container: fix missing blank lines after declarations Found with checkpatch.pl Signed-off-by: Cosmin Dragomir Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c index 3ead3af..2ba4cac 100644 --- a/drivers/base/attribute_container.c +++ b/drivers/base/attribute_container.c @@ -94,6 +94,7 @@ int attribute_container_unregister(struct attribute_container *cont) { int retval = -EBUSY; + mutex_lock(&attribute_container_mutex); spin_lock(&cont->containers.k_lock); if (!list_empty(&cont->containers.k_list)) @@ -349,6 +350,7 @@ int attribute_container_add_class_device(struct device *classdev) { int error = device_add(classdev); + if (error) return error; return attribute_container_add_attrs(classdev); -- cgit v0.10.2 From d34898de9a43bf79b274c8c6a43bf2f6f76dac05 Mon Sep 17 00:00:00 2001 From: Cosmin Tomulescu Date: Sun, 8 Mar 2015 12:31:54 +0200 Subject: drivers: base: class: Add a blank line after declarations This patch fixes the following warning found by checkpatch.pl: WARNING: Missing a black line after declarations Signed-off-by: Cosmin Tomulescu Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/class.c b/drivers/base/class.c index f96f704..6e81088 100644 --- a/drivers/base/class.c +++ b/drivers/base/class.c @@ -90,6 +90,7 @@ int class_create_file_ns(struct class *cls, const struct class_attribute *attr, const void *ns) { int error; + if (cls) error = sysfs_create_file_ns(&cls->p->subsys.kobj, &attr->attr, ns); @@ -488,6 +489,7 @@ ssize_t show_class_attr_string(struct class *class, struct class_attribute *attr, char *buf) { struct class_attribute_string *cs; + cs = container_of(attr, struct class_attribute_string, attr); return snprintf(buf, PAGE_SIZE, "%s\n", cs->str); } -- cgit v0.10.2 From 6d42d79e640fd1cd8fd97d11c8693f8907fc4eac Mon Sep 17 00:00:00 2001 From: Marius Cristian Eseanu Date: Sun, 8 Mar 2015 12:34:14 +0200 Subject: drivers: base: dma-mapping: Erase blank space after pointer This patch fixes the following checkpatch.pl error: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Marius Cristian Eseanu Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/dma-mapping.c b/drivers/base/dma-mapping.c index 9e8bbdd..d95c597 100644 --- a/drivers/base/dma-mapping.c +++ b/drivers/base/dma-mapping.c @@ -62,7 +62,7 @@ static int dmam_match(struct device *dev, void *res, void *match_data) * RETURNS: * Pointer to allocated memory on success, NULL on failure. */ -void * dmam_alloc_coherent(struct device *dev, size_t size, +void *dmam_alloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t gfp) { struct dma_devres *dr; -- cgit v0.10.2 From ea31003ccb2d684916cb7ebc079437ae85425a6d Mon Sep 17 00:00:00 2001 From: Andrei Oprea Date: Sun, 8 Mar 2015 12:41:15 +0200 Subject: firmware_class: Fix whitespace and indentation Fix checkpatch.pl issues with coding style. Removed whitespace and fixed indentation Signed-off-by: Andrei Oprea Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 6c5c9ed..710540f 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -181,7 +181,7 @@ static struct firmware_buf *__allocate_fw_buf(const char *fw_name, { struct firmware_buf *buf; - buf = kzalloc(sizeof(*buf) + strlen(fw_name) + 1 , GFP_ATOMIC); + buf = kzalloc(sizeof(*buf) + strlen(fw_name) + 1, GFP_ATOMIC); if (!buf) return buf; @@ -1168,7 +1168,7 @@ _request_firmware(const struct firmware **firmware_p, const char *name, **/ int request_firmware(const struct firmware **firmware_p, const char *name, - struct device *device) + struct device *device) { int ret; @@ -1196,6 +1196,7 @@ int request_firmware_direct(const struct firmware **firmware_p, const char *name, struct device *device) { int ret; + __module_get(THIS_MODULE); ret = _request_firmware(firmware_p, name, device, FW_OPT_UEVENT | FW_OPT_NO_WARN); @@ -1276,7 +1277,7 @@ request_firmware_nowait( { struct firmware_work *fw_work; - fw_work = kzalloc(sizeof (struct firmware_work), gfp); + fw_work = kzalloc(sizeof(struct firmware_work), gfp); if (!fw_work) return -ENOMEM; -- cgit v0.10.2 From 2aeebca2f3586755802689e12ba87140d803d88a Mon Sep 17 00:00:00 2001 From: Ioana Ciornei Date: Sun, 8 Mar 2015 12:48:35 +0200 Subject: drivers: base: memory: Use tabs instead of spaces This patch changes spaces to tabs. Found using checkpatch.pl Signed-off-by: Ioana Ciornei Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/memory.c b/drivers/base/memory.c index eb461cf..af9c911 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c @@ -52,13 +52,13 @@ static BLOCKING_NOTIFIER_HEAD(memory_chain); int register_memory_notifier(struct notifier_block *nb) { - return blocking_notifier_chain_register(&memory_chain, nb); + return blocking_notifier_chain_register(&memory_chain, nb); } EXPORT_SYMBOL(register_memory_notifier); void unregister_memory_notifier(struct notifier_block *nb) { - blocking_notifier_chain_unregister(&memory_chain, nb); + blocking_notifier_chain_unregister(&memory_chain, nb); } EXPORT_SYMBOL(unregister_memory_notifier); -- cgit v0.10.2 From 518d3f38abb8cc3a5125e71a1d23a366c69e2e49 Mon Sep 17 00:00:00 2001 From: Ana Nedelcu Date: Sun, 8 Mar 2015 12:48:48 +0200 Subject: drivers: base: node: Delete space after pointer declaration This patch fixes the following error found by checkpatch.pl: ERROR: "foo * bar" should be "foo *bar" Signed-off-by: Ana Nedelcu Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/node.c b/drivers/base/node.c index 6356866..a2aa65b 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c @@ -180,7 +180,7 @@ static ssize_t node_read_vmstat(struct device *dev, static DEVICE_ATTR(vmstat, S_IRUGO, node_read_vmstat, NULL); static ssize_t node_read_distance(struct device *dev, - struct device_attribute *attr, char * buf) + struct device_attribute *attr, char *buf) { int nid = dev->id; int len = 0; -- cgit v0.10.2 From 74642c6cd088e124c3cccbd5cb2f54984d6d4e1a Mon Sep 17 00:00:00 2001 From: Lavinia Tache Date: Sun, 8 Mar 2015 12:48:55 +0200 Subject: driver core: add missing blank line after declaration Found using checkpatch.pl Signed-off-by: Lavinia Tache Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/driver.c b/drivers/base/driver.c index 9e29943..4eabfe2 100644 --- a/drivers/base/driver.c +++ b/drivers/base/driver.c @@ -103,6 +103,7 @@ int driver_create_file(struct device_driver *drv, const struct driver_attribute *attr) { int error; + if (drv) error = sysfs_create_file(&drv->p->kobj, &attr->attr); else -- cgit v0.10.2 From 2071b9502dadffd22ac1bc31c68728e2783ec3ac Mon Sep 17 00:00:00 2001 From: Lavinia Tache Date: Sun, 8 Mar 2015 22:33:44 +0200 Subject: drivers/base: use tabs where possible in code indentation Linux kernel coding style require that tabs should be used instead of spaces for code indentation. Problem found using checkpatch.pl script. Signed-off-by: Lavinia Tache Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/soc.c b/drivers/base/soc.c index 72b5e72..39fca01 100644 --- a/drivers/base/soc.c +++ b/drivers/base/soc.c @@ -43,8 +43,8 @@ struct device *soc_device_to_device(struct soc_device *soc_dev) } static umode_t soc_attribute_mode(struct kobject *kobj, - struct attribute *attr, - int index) + struct attribute *attr, + int index) { struct device *dev = container_of(kobj, struct device, kobj); struct soc_device *soc_dev = container_of(dev, struct soc_device, dev); @@ -60,7 +60,7 @@ static umode_t soc_attribute_mode(struct kobject *kobj, return attr->mode; if ((attr == &dev_attr_soc_id.attr) && (soc_dev->attr->soc_id != NULL)) - return attr->mode; + return attr->mode; /* Unknown or unfilled attribute. */ return 0; @@ -117,7 +117,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr soc_dev = kzalloc(sizeof(*soc_dev), GFP_KERNEL); if (!soc_dev) { - ret = -ENOMEM; + ret = -ENOMEM; goto out1; } @@ -135,7 +135,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr } while (ret == -EAGAIN); if (ret) - goto out2; + goto out2; soc_dev->attr = soc_dev_attr; soc_dev->dev.bus = &soc_bus_type; -- cgit v0.10.2 From 8a7d95f95c95f396decbd4cda6d4903fc4664946 Mon Sep 17 00:00:00 2001 From: Sudeep Holla Date: Tue, 17 Mar 2015 17:28:46 +0000 Subject: drivers/base: cacheinfo: validate device node for all the caches On architectures that depend on DT for obtaining cache hierarcy, we need to validate the device node for all the cache indices, failing to do so might result in wrong information being exposed to the userspace. This is quite possible on initial/incomplete versions of the device trees. In such cases, it's better to bail out if all the required device nodes are not present. This patch adds checks for the validation of device node for all the caches and doesn't initialise the cacheinfo if there's any error. Reported-by: Mark Rutland Acked-by: Mark Rutland Signed-off-by: Sudeep Holla Cc: stable # 4.0 Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/cacheinfo.c b/drivers/base/cacheinfo.c index 6e64563..9c2ba1c 100644 --- a/drivers/base/cacheinfo.c +++ b/drivers/base/cacheinfo.c @@ -62,15 +62,21 @@ static int cache_setup_of_node(unsigned int cpu) return -ENOENT; } - while (np && index < cache_leaves(cpu)) { + while (index < cache_leaves(cpu)) { this_leaf = this_cpu_ci->info_list + index; if (this_leaf->level != 1) np = of_find_next_cache_node(np); else np = of_node_get(np);/* cpu node itself */ + if (!np) + break; this_leaf->of_node = np; index++; } + + if (index != cache_leaves(cpu)) /* not all OF nodes populated */ + return -ENOENT; + return 0; } @@ -189,8 +195,11 @@ static int detect_cache_attributes(unsigned int cpu) * will be set up here only if they are not populated already */ ret = cache_shared_cpu_map_setup(cpu); - if (ret) + if (ret) { + pr_warn("Unable to detect cache hierarcy from DT for CPU %d\n", + cpu); goto free_ci; + } return 0; free_ci: -- cgit v0.10.2 From 46239902ecddd4690b6d800da258d0ab65a5cb78 Mon Sep 17 00:00:00 2001 From: Takashi Iwai Date: Wed, 4 Feb 2015 15:18:07 +0100 Subject: firmware: Avoid manual device_create_file() calls Use the static attribute groups assigned to the device instead of manual device_create_file() & co calls. It simplifies the code and can avoid possible races, too. Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 710540f..1b5bfd7 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -835,6 +835,26 @@ static struct bin_attribute firmware_attr_data = { .write = firmware_data_write, }; +static struct attribute *fw_dev_attrs[] = { + &dev_attr_loading.attr, + NULL +}; + +static struct bin_attribute *fw_dev_bin_attrs[] = { + &firmware_attr_data, + NULL +}; + +static const struct attribute_group fw_dev_attr_group = { + .attrs = fw_dev_attrs, + .bin_attrs = fw_dev_bin_attrs, +}; + +static const struct attribute_group *fw_dev_attr_groups[] = { + &fw_dev_attr_group, + NULL +}; + static struct firmware_priv * fw_create_instance(struct firmware *firmware, const char *fw_name, struct device *device, unsigned int opt_flags) @@ -856,6 +876,7 @@ fw_create_instance(struct firmware *firmware, const char *fw_name, dev_set_name(f_dev, "%s", fw_name); f_dev->parent = device; f_dev->class = &firmware_class; + f_dev->groups = fw_dev_attr_groups; exit: return fw_priv; } @@ -879,25 +900,10 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, goto err_put_dev; } - retval = device_create_bin_file(f_dev, &firmware_attr_data); - if (retval) { - dev_err(f_dev, "%s: sysfs_create_bin_file failed\n", __func__); - goto err_del_dev; - } - mutex_lock(&fw_lock); list_add(&buf->pending_list, &pending_fw_head); mutex_unlock(&fw_lock); - retval = device_create_file(f_dev, &dev_attr_loading); - if (retval) { - mutex_lock(&fw_lock); - list_del_init(&buf->pending_list); - mutex_unlock(&fw_lock); - dev_err(f_dev, "%s: device_create_file failed\n", __func__); - goto err_del_bin_attr; - } - if (opt_flags & FW_OPT_UEVENT) { buf->need_uevent = true; dev_set_uevent_suppress(f_dev, false); @@ -920,10 +926,6 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, else if (!buf->data) retval = -ENOMEM; - device_remove_file(f_dev, &dev_attr_loading); -err_del_bin_attr: - device_remove_bin_file(f_dev, &firmware_attr_data); -err_del_dev: device_del(f_dev); err_put_dev: put_device(f_dev); -- cgit v0.10.2 From ef518cc8aa4427043efe21cb2f0799be9cb1d74d Mon Sep 17 00:00:00 2001 From: Zahari Doychev Date: Tue, 10 Mar 2015 10:45:40 +0100 Subject: drivers: base: fw: fix ret value when loading fw When using the user mode helper to load firmwares the function _request_firmware gets a positive return value from fw_load_from_user_helper and because of this the firmware buffer is not assigned. This happens only when the return value is zero. This patch fixes this problem in _request_firmware_load. When the completion is ready the return value is set to zero. Signed-off-by: Zahari Doychev Cc: Ming Lei Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c index 1b5bfd7..171841a 100644 --- a/drivers/base/firmware_class.c +++ b/drivers/base/firmware_class.c @@ -919,6 +919,8 @@ static int _request_firmware_load(struct firmware_priv *fw_priv, mutex_lock(&fw_lock); fw_load_abort(fw_priv); mutex_unlock(&fw_lock); + } else if (retval > 0) { + retval = 0; } if (is_fw_load_aborted(buf)) -- cgit v0.10.2 From e8a51e1b51ee5730ad3913f3962e3099a5e19359 Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Tue, 17 Feb 2015 19:03:41 -0600 Subject: device: Add dev_of_node() accessor Suggested by Arnd Bergmann, this gives a practical accessor for the of_node field of struct device while instructing the compiler that it will be NULL if CONFIG_OF is not set. Signed-off-by: Benjamin Herrenschmidt Acked-by: Rob Herring Signed-off-by: Greg Kroah-Hartman diff --git a/include/linux/device.h b/include/linux/device.h index 0eb8ee2..f3f2c7e 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -916,6 +916,13 @@ static inline void device_lock_assert(struct device *dev) lockdep_assert_held(&dev->mutex); } +static inline struct device_node *dev_of_node(struct device *dev) +{ + if (!IS_ENABLED(CONFIG_OF)) + return NULL; + return dev->of_node; +} + void driver_init(void); /* -- cgit v0.10.2 From 5590f3196b293574a12be58d06d5e1120d8856ec Mon Sep 17 00:00:00 2001 From: Benjamin Herrenschmidt Date: Wed, 18 Feb 2015 11:25:18 +1100 Subject: drivers/core/of: Add symlink to device-tree from devices with an OF node So I've been annoyed lately with having a bunch of devices such as i2c eeproms (for use by VPDs, server world !) and other bits and pieces that I want to be able to identify from userspace, and possibly provide additional data about from FW. Basically, it boils down to correlating the sysfs device with the OF tree device node, so that user space can use device-tree info such as additional "location" or "label" (or whatever else we can come up with) propreties to identify a given device, or get some attributes of use about it, etc... Now, so far, we've done that in some subsystem in a fairly ad-hoc basis using "devspec" properties. For example, PCI creates them if it can correlate the probed device with a DT node. Some powerpc specific busses do that too. However, i2c doesn't and it would be nice to have something more generic since technically any device can have a corresponding device tree node. This patch adds an "of_node" symlink to devices that have a non-NULL dev->of_node pointer, the patch is pretty trivial and seems to work just fine for me. Signed-off-by: Benjamin Herrenschmidt Acked-by: Rob Herring Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/ABI/stable/sysfs-devices b/Documentation/ABI/stable/sysfs-devices new file mode 100644 index 0000000..43f78b88d --- /dev/null +++ b/Documentation/ABI/stable/sysfs-devices @@ -0,0 +1,10 @@ +# Note: This documents additional properties of any device beyond what +# is documented in Documentation/sysfs-rules.txt + +What: /sys/devices/*/of_path +Date: February 2015 +Contact: Device Tree mailing list +Description: + Any device associated with a device-tree node will have + an of_path symlink pointing to the corresponding device + node in /sys/firmware/devicetree/ diff --git a/drivers/base/core.c b/drivers/base/core.c index e0998b6..cadf165 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -805,8 +805,16 @@ static void cleanup_device_parent(struct device *dev) static int device_add_class_symlinks(struct device *dev) { + struct device_node *of_node = dev_of_node(dev); int error; + if (of_node) { + error = sysfs_create_link(&dev->kobj, &of_node->kobj,"of_node"); + if (error) + dev_warn(dev, "Error %d creating of_node link\n",error); + /* An error here doesn't warrant bringing down the device */ + } + if (!dev->class) return 0; @@ -814,7 +822,7 @@ static int device_add_class_symlinks(struct device *dev) &dev->class->p->subsys.kobj, "subsystem"); if (error) - goto out; + goto out_devnode; if (dev->parent && device_is_not_partition(dev)) { error = sysfs_create_link(&dev->kobj, &dev->parent->kobj, @@ -842,12 +850,16 @@ out_device: out_subsys: sysfs_remove_link(&dev->kobj, "subsystem"); -out: +out_devnode: + sysfs_remove_link(&dev->kobj, "of_node"); return error; } static void device_remove_class_symlinks(struct device *dev) { + if (dev_of_node(dev)) + sysfs_remove_link(&dev->kobj, "of_node"); + if (!dev->class) return; -- cgit v0.10.2 From 13fcffbbdec4e4863a9a9c7792b821cd6d363a8f Mon Sep 17 00:00:00 2001 From: Mark Brown Date: Tue, 10 Mar 2015 11:55:49 +0000 Subject: driver core: Make probe deferral more quiet Currently probe deferral prints a message every time a device requests deferral at info severity (which is displayed by default). This can have an impact on system boot times with serial consoles and is generally quite noisy. Since subsystems and drivers should already be logging the specific reason for probe deferral in order to aid users in understanding problems the messages from the driver core should be redundant lower the severity of the messages printed, cutting down on the volume of output on the console. This does mean that if the drivers and subsystems aren't doing a good job we get no output on the console by default. Ideally we'd be able to arrange to print if nothing else printed, though that's a little fun. Even better would be to come up with a mechanism that explicitly does dependencies so we don't have to keep polling and erroring. Signed-off-by: Mark Brown Reviewed-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/dd.c b/drivers/base/dd.c index bfece0c..49a4a12 100644 --- a/drivers/base/dd.c +++ b/drivers/base/dd.c @@ -323,7 +323,7 @@ probe_failed: switch (ret) { case -EPROBE_DEFER: /* Driver requested deferred probing */ - dev_info(dev, "Driver %s requests probe deferral\n", drv->name); + dev_dbg(dev, "Driver %s requests probe deferral\n", drv->name); driver_deferred_probe_add(dev); /* Did a trigger occur while probing? Need to re-trigger if yes */ if (local_trigger_count != atomic_read(&deferred_trigger_count)) -- cgit v0.10.2 From 7085a7401ba54e92bbb5aa24d6f428071e18e509 Mon Sep 17 00:00:00 2001 From: Linus Walleij Date: Wed, 18 Feb 2015 17:12:18 +0100 Subject: drivers: platform: parse IRQ flags from resources This fixes a regression from the net subsystem: After commit d52fdbb735c36a209f36a628d40ca9185b349ba7 "smc91x: retrieve IRQ and trigger flags in a modern way" a regression would appear on some legacy platforms such as the ARM PXA Zylonite that specify IRQ resources like this: static struct resource r = { .start = X, .end = X, .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE, }; The previous code would retrieve the resource and parse the high edge setting in the SMC91x driver, a use pattern that means every driver specifying an IRQ flag from a static resource need to parse resource flags and apply them at runtime. As we switched the code to use IRQ descriptors to retrieve the the trigger type like this: irqd_get_trigger_type(irq_get_irq_data(...)); the code would work for new platforms using e.g. device tree as the backing irq descriptor would have its flags properly set, whereas this kind of oldstyle static resources at no point assign the trigger flags to the corresponding IRQ descriptor. To make the behaviour identical on modern device tree and legacy static platform data platforms, modify platform_get_irq() to assign the trigger flags to the irq descriptor when a client looks up an IRQ from static resources. Fixes: d52fdbb735c3 ("smc91x: retrieve IRQ and trigger flags in a modern way") Tested-by: Robert Jarzmik Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 9421fed..e68ab79 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -101,6 +101,15 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) } r = platform_get_resource(dev, IORESOURCE_IRQ, num); + /* + * The resources may pass trigger flags to the irqs that need + * to be set up. It so happens that the trigger flags for + * IORESOURCE_BITS correspond 1-to-1 to the IRQF_TRIGGER* + * settings. + */ + if (r && r->flags & IORESOURCE_BITS) + irqd_set_trigger_type(irq_get_irq_data(r->start), + r->flags & IORESOURCE_BITS); return r ? r->start : -ENXIO; #endif -- cgit v0.10.2 From bea2b592fd18eb8ffa3fc4ad380610632d03a38f Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 10 Feb 2015 11:12:21 +0100 Subject: lib/lz4: Pull out constant tables There's no reason to allocate the dec{32,64}table on the stack; it just wastes a bunch of instructions setting them up and, of course, also consumes quite a bit of stack. Using size_t for such small integers is a little excessive. $ scripts/bloat-o-meter /tmp/built-in.o lib/built-in.o add/remove: 2/2 grow/shrink: 2/0 up/down: 1304/-1548 (-244) function old new delta lz4_decompress_unknownoutputsize 55 718 +663 lz4_decompress 55 632 +577 dec64table - 32 +32 dec32table - 32 +32 lz4_uncompress 747 - -747 lz4_uncompress_unknownoutputsize 801 - -801 The now inlined lz4_uncompress functions used to have a stack footprint of 176 bytes (according to -fstack-usage); their inlinees have increased their stack use from 32 bytes to 48 and 80 bytes, respectively. Signed-off-by: Rasmus Villemoes Signed-off-by: Greg Kroah-Hartman diff --git a/lib/lz4/lz4_decompress.c b/lib/lz4/lz4_decompress.c index f0f5c5c..26cc602 100644 --- a/lib/lz4/lz4_decompress.c +++ b/lib/lz4/lz4_decompress.c @@ -47,6 +47,11 @@ #include "lz4defs.h" +static const int dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; +#if LZ4_ARCH64 +static const int dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; +#endif + static int lz4_uncompress(const char *source, char *dest, int osize) { const BYTE *ip = (const BYTE *) source; @@ -56,10 +61,6 @@ static int lz4_uncompress(const char *source, char *dest, int osize) BYTE *cpy; unsigned token; size_t length; - size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; -#if LZ4_ARCH64 - size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; -#endif while (1) { @@ -116,7 +117,7 @@ static int lz4_uncompress(const char *source, char *dest, int osize) /* copy repeated sequence */ if (unlikely((op - ref) < STEPSIZE)) { #if LZ4_ARCH64 - size_t dec64 = dec64table[op - ref]; + int dec64 = dec64table[op - ref]; #else const int dec64 = 0; #endif @@ -177,11 +178,6 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, BYTE * const oend = op + maxoutputsize; BYTE *cpy; - size_t dec32table[] = {0, 3, 2, 3, 0, 0, 0, 0}; -#if LZ4_ARCH64 - size_t dec64table[] = {0, 0, 0, -1, 0, 1, 2, 3}; -#endif - /* Main Loop */ while (ip < iend) { @@ -249,7 +245,7 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, /* copy repeated sequence */ if (unlikely((op - ref) < STEPSIZE)) { #if LZ4_ARCH64 - size_t dec64 = dec64table[op - ref]; + int dec64 = dec64table[op - ref]; #else const int dec64 = 0; #endif -- cgit v0.10.2 From d82d54af7b14092dc5934a8ce09170789c9ddb57 Mon Sep 17 00:00:00 2001 From: Ethan Zhao Date: Thu, 12 Mar 2015 13:04:16 +0900 Subject: kobject: WARN as tip when call kobject_get() to a kobject not initialized call kobject_get() to kojbect that is not initalized or released will only leave following like call trace to us: -----------[ cut here ]------------ [ 54.545816] WARNING: CPU: 0 PID: 213 at include/linux/kref.h:47 kobject_get+0x41/0x50() [ 54.642595] Modules linked in: i2c_i801(+) mfd_core shpchp(+) acpi_cpufreq(+) edac_core ioatdma(+) xfs libcrc32c ast syscopyarea ixgbe sysfillrect sysimgblt sr_mod sd_mod drm_kms_helper igb mdio cdrom e1000e ahci dca ttm libahci uas drm i2c_algo_bit ptp megaraid_sas libata usb_storage i2c_core pps_core dm_mirror dm_region_hash dm_log dm_mod [ 55.007264] CPU: 0 PID: 213 Comm: kworker/0:2 Not tainted 3.18.5 [ 55.099970] Hardware name: Oracle Corporation SUN FIRE X4170 M2 SERVER /ASSY,MOTHERBOARD,X4170, BIOS 08120104 05/08/2012 [ 55.239736] Workqueue: kacpi_notify acpi_os_execute_deferred [ 55.308598] 0000000000000000 00000000bd730b61 ffff88046742baf8 ffffffff816b7edb [ 55.398305] 0000000000000000 0000000000000000 ffff88046742bb38 ffffffff81078ae1 [ 55.488040] ffff88046742bbd8 ffff8806706b3000 0000000000000292 0000000000000000 [ 55.577776] Call Trace: [ 55.608228] [] dump_stack+0x46/0x58 [ 55.670895] [] warn_slowpath_common+0x81/0xa0 [ 55.743952] [] warn_slowpath_null+0x1a/0x20 [ 55.814929] [] kobject_get+0x41/0x50 [ 55.878654] [] cpufreq_cpu_get+0x75/0xc0 [ 55.946528] [] cpufreq_update_policy+0x2e/0x1f0 The above issue was casued by a race condition, if there is a WARN in kobject_get() of the kobject is not initialized, that would save us much time to debug it. Signed-off-by: Ethan Zhao Signed-off-by: Greg Kroah-Hartman diff --git a/lib/kobject.c b/lib/kobject.c index 03d4ab3..3b841b9 100644 --- a/lib/kobject.c +++ b/lib/kobject.c @@ -576,8 +576,13 @@ void kobject_del(struct kobject *kobj) */ struct kobject *kobject_get(struct kobject *kobj) { - if (kobj) + if (kobj) { + if (!kobj->state_initialized) + WARN(1, KERN_WARNING "kobject: '%s' (%p): is not " + "initialized, yet kobject_get() is being " + "called.\n", kobject_name(kobj), kobj); kref_get(&kobj->kref); + } return kobj; } -- cgit v0.10.2 From fdc81b7910ad5153bf257e5f7861be71f75a02ef Mon Sep 17 00:00:00 2001 From: David Daney Date: Thu, 26 Mar 2015 10:09:08 -0700 Subject: stable_kernel_rules: Add clause about specification of kernel versions to patch. Signed-off-by: David Daney Signed-off-by: Greg Kroah-Hartman diff --git a/Documentation/stable_kernel_rules.txt b/Documentation/stable_kernel_rules.txt index 02f8331..58d0ac4 100644 --- a/Documentation/stable_kernel_rules.txt +++ b/Documentation/stable_kernel_rules.txt @@ -81,6 +81,16 @@ format in the sign-off area: git cherry-pick fd21073 git cherry-pick +Also, some patches may have kernel version prerequisites. This can be +specified in the following format in the sign-off area: + + Cc: # 3.3.x- + + The tag has the meaning of: + git cherry-pick + + For each "-stable" tree starting with the specified version. + Following the submission: - The sender will receive an ACK when the patch has been accepted into the -- cgit v0.10.2 From c9e15f25f514a76d906be01e621f400cdee94558 Mon Sep 17 00:00:00 2001 From: Greg KH Date: Mon, 30 Mar 2015 14:59:15 +0200 Subject: debugfs: allow bad parent pointers to be passed in If something went wrong with creating a debugfs file/symlink/directory, that value could be passed down into debugfs again as a parent dentry. To make caller code simpler, just error out if this happens, and don't crash the kernel. Reported-by: Alex Elder Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman Reviewed-by: Alex Elder diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c index 96400ab..61e72d4 100644 --- a/fs/debugfs/inode.c +++ b/fs/debugfs/inode.c @@ -254,6 +254,9 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) pr_debug("debugfs: creating file '%s'\n",name); + if (IS_ERR(parent)) + return parent; + error = simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count); if (error) -- cgit v0.10.2