Skip to content

Commit e35be05

Browse files
committed
Merge tag 'driver-core-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
Pull driver core fixes from Greg KH: "Here are some small driver core and debugfs fixes for 6.0-rc5. Included in here are: - multiple attempts to get the arch_topology code to work properly on non-cluster SMT systems. First attempt caused build breakages in linux-next and 0-day, second try worked. - debugfs fixes for a long-suffering memory leak. The pattern of debugfs_remove(debugfs_lookup(...)) turns out to leak dentries, so add debugfs_lookup_and_remove() to fix this problem. Also fix up the scheduler debug code that highlighted this problem. Fixes for other subsystems will be trickling in over the next few months for this same issue once the debugfs function is merged. All of these have been in linux-next since Wednesday with no reported problems" * tag 'driver-core-6.0-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: arch_topology: Make cluster topology span at least SMT CPUs sched/debug: fix dentry leak in update_sched_domain_debugfs debugfs: add debugfs_lookup_and_remove() driver core: fix driver_set_override() issue with empty strings Revert "arch_topology: Make cluster topology span at least SMT CPUs" arch_topology: Make cluster topology span at least SMT CPUs
2 parents 9ebc0ec + 5ac251c commit e35be05

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

drivers/base/arch_topology.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ const struct cpumask *cpu_clustergroup_mask(int cpu)
724724
*/
725725
if (cpumask_subset(cpu_coregroup_mask(cpu),
726726
&cpu_topology[cpu].cluster_sibling))
727-
return get_cpu_mask(cpu);
727+
return topology_sibling_cpumask(cpu);
728728

729729
return &cpu_topology[cpu].cluster_sibling;
730730
}

drivers/base/driver.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ int driver_set_override(struct device *dev, const char **override,
6363
if (len >= (PAGE_SIZE - 1))
6464
return -EINVAL;
6565

66+
/*
67+
* Compute the real length of the string in case userspace sends us a
68+
* bunch of \0 characters like python likes to do.
69+
*/
70+
len = strlen(s);
71+
6672
if (!len) {
6773
/* Empty string passed - clear override */
6874
device_lock(dev);

fs/debugfs/inode.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,28 @@ void debugfs_remove(struct dentry *dentry)
744744
}
745745
EXPORT_SYMBOL_GPL(debugfs_remove);
746746

747+
/**
748+
* debugfs_lookup_and_remove - lookup a directory or file and recursively remove it
749+
* @name: a pointer to a string containing the name of the item to look up.
750+
* @parent: a pointer to the parent dentry of the item.
751+
*
752+
* This is the equlivant of doing something like
753+
* debugfs_remove(debugfs_lookup(..)) but with the proper reference counting
754+
* handled for the directory being looked up.
755+
*/
756+
void debugfs_lookup_and_remove(const char *name, struct dentry *parent)
757+
{
758+
struct dentry *dentry;
759+
760+
dentry = debugfs_lookup(name, parent);
761+
if (!dentry)
762+
return;
763+
764+
debugfs_remove(dentry);
765+
dput(dentry);
766+
}
767+
EXPORT_SYMBOL_GPL(debugfs_lookup_and_remove);
768+
747769
/**
748770
* debugfs_rename - rename a file/directory in the debugfs filesystem
749771
* @old_dir: a pointer to the parent dentry for the renamed object. This

include/linux/debugfs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ struct dentry *debugfs_create_automount(const char *name,
9191
void debugfs_remove(struct dentry *dentry);
9292
#define debugfs_remove_recursive debugfs_remove
9393

94+
void debugfs_lookup_and_remove(const char *name, struct dentry *parent);
95+
9496
const struct file_operations *debugfs_real_fops(const struct file *filp);
9597

9698
int debugfs_file_get(struct dentry *dentry);
@@ -225,6 +227,10 @@ static inline void debugfs_remove(struct dentry *dentry)
225227
static inline void debugfs_remove_recursive(struct dentry *dentry)
226228
{ }
227229

230+
static inline void debugfs_lookup_and_remove(const char *name,
231+
struct dentry *parent)
232+
{ }
233+
228234
const struct file_operations *debugfs_real_fops(const struct file *filp);
229235

230236
static inline int debugfs_file_get(struct dentry *dentry)

kernel/sched/debug.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ void update_sched_domain_debugfs(void)
416416
char buf[32];
417417

418418
snprintf(buf, sizeof(buf), "cpu%d", cpu);
419-
debugfs_remove(debugfs_lookup(buf, sd_dentry));
419+
debugfs_lookup_and_remove(buf, sd_dentry);
420420
d_cpu = debugfs_create_dir(buf, sd_dentry);
421421

422422
i = 0;

0 commit comments

Comments
 (0)