Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66747138 authored by Denis V. Lunev's avatar Denis V. Lunev Committed by Linus Torvalds
Browse files

powerpc: use non-racy method for proc entries creation



Use proc_create()/proc_create_data() to make sure that ->proc_fops and ->data
be setup before gluing PDE to main tree.

Add correct ->owner to proc_fops to fix reading/module unloading race.

Signed-off-by: default avatarDenis V. Lunev <den@openvz.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 6f1c86ec
Loading
Loading
Loading
Loading
+2 −4
Original line number Diff line number Diff line
@@ -591,10 +591,8 @@ int __init lparcfg_init(void)
			!firmware_has_feature(FW_FEATURE_ISERIES))
		mode |= S_IWUSR;

	ent = create_proc_entry("ppc64/lparcfg", mode, NULL);
	if (ent) {
		ent->proc_fops = &lparcfg_fops;
	} else {
	ent = proc_create("ppc64/lparcfg", mode, NULL, &lparcfg_fops);
	if (!ent) {
		printk(KERN_ERR "Failed to create ppc64/lparcfg\n");
		return -EIO;
	}
+2 −3
Original line number Diff line number Diff line
@@ -68,12 +68,11 @@ static int __init proc_ppc64_init(void)
{
	struct proc_dir_entry *pde;

	pde = create_proc_entry("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL);
	pde = proc_create_data("ppc64/systemcfg", S_IFREG|S_IRUGO, NULL,
			       &page_map_fops, vdso_data);
	if (!pde)
		return 1;
	pde->data = vdso_data;
	pde->size = PAGE_SIZE;
	pde->proc_fops = &page_map_fops;

	return 0;
}
+14 −31
Original line number Diff line number Diff line
@@ -255,8 +255,6 @@ static void check_location(struct seq_file *m, const char *c);

static int __init proc_rtas_init(void)
{
	struct proc_dir_entry *entry;

	if (!machine_is(pseries))
		return -ENODEV;

@@ -264,35 +262,20 @@ static int __init proc_rtas_init(void)
	if (rtas_node == NULL)
		return -ENODEV;

	entry = create_proc_entry("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_progress_operations;

	entry = create_proc_entry("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_clock_operations;

	entry = create_proc_entry("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_poweron_operations;

	entry = create_proc_entry("ppc64/rtas/sensors", S_IRUGO, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_sensors_operations;

	entry = create_proc_entry("ppc64/rtas/frequency", S_IWUSR|S_IRUGO,
				  NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_tone_freq_operations;

	entry = create_proc_entry("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_tone_volume_operations;

	entry = create_proc_entry("ppc64/rtas/rmo_buffer", S_IRUSR, NULL);
	if (entry)
		entry->proc_fops = &ppc_rtas_rmo_buf_ops;

	proc_create("ppc64/rtas/progress", S_IRUGO|S_IWUSR, NULL,
		    &ppc_rtas_progress_operations);
	proc_create("ppc64/rtas/clock", S_IRUGO|S_IWUSR, NULL,
		    &ppc_rtas_clock_operations);
	proc_create("ppc64/rtas/poweron", S_IWUSR|S_IRUGO, NULL,
		    &ppc_rtas_poweron_operations);
	proc_create("ppc64/rtas/sensors", S_IRUGO, NULL,
		    &ppc_rtas_sensors_operations);
	proc_create("ppc64/rtas/frequency", S_IWUSR|S_IRUGO, NULL,
		    &ppc_rtas_tone_freq_operations);
	proc_create("ppc64/rtas/volume", S_IWUSR|S_IRUGO, NULL,
		    &ppc_rtas_tone_volume_operations);
	proc_create("ppc64/rtas/rmo_buffer", S_IRUSR, NULL,
		    &ppc_rtas_rmo_buf_ops);
	return 0;
}

+4 −9
Original line number Diff line number Diff line
@@ -704,18 +704,11 @@ static int initialize_flash_pde_data(const char *rtas_call_name,
static struct proc_dir_entry *create_flash_pde(const char *filename,
					       const struct file_operations *fops)
{
	struct proc_dir_entry *ent = NULL;

	ent = create_proc_entry(filename, S_IRUSR | S_IWUSR, NULL);
	if (ent != NULL) {
		ent->proc_fops = fops;
		ent->owner = THIS_MODULE;
	}

	return ent;
	return proc_create(filename, S_IRUSR | S_IWUSR, NULL, fops);
}

static const struct file_operations rtas_flash_operations = {
	.owner		= THIS_MODULE,
	.read		= rtas_flash_read,
	.write		= rtas_flash_write,
	.open		= rtas_excl_open,
@@ -723,6 +716,7 @@ static const struct file_operations rtas_flash_operations = {
};

static const struct file_operations manage_flash_operations = {
	.owner		= THIS_MODULE,
	.read		= manage_flash_read,
	.write		= manage_flash_write,
	.open		= rtas_excl_open,
@@ -730,6 +724,7 @@ static const struct file_operations manage_flash_operations = {
};

static const struct file_operations validate_flash_operations = {
	.owner		= THIS_MODULE,
	.read		= validate_flash_read,
	.write		= validate_flash_write,
	.open		= rtas_excl_open,
+1 −2
Original line number Diff line number Diff line
@@ -1063,10 +1063,9 @@ int __init spu_sched_init(void)

	mod_timer(&spuloadavg_timer, 0);

	entry = create_proc_entry("spu_loadavg", 0, NULL);
	entry = proc_create("spu_loadavg", 0, NULL, &spu_loadavg_fops);
	if (!entry)
		goto out_stop_kthread;
	entry->proc_fops = &spu_loadavg_fops;

	pr_debug("spusched: tick: %d, min ticks: %d, default ticks: %d\n",
			SPUSCHED_TICK, MIN_SPU_TIMESLICE, DEF_SPU_TIMESLICE);
Loading