mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Randy.Dunlap" <rdunlap@xenotime.net>
To: lkml <linux-kernel@vger.kernel.org>
Cc: akpm@osdl.org, gregkh <greg@kroah.com>
Subject: [PATCH -mm] sysfs_remove_bin_file: no return value, dump_stack on error
Date: Mon, 10 Jul 2006 23:05:25 -0700	[thread overview]
Message-ID: <20060710230525.860d0caa.rdunlap@xenotime.net> (raw)
In-Reply-To: <20060710173636.35008ada.rdunlap@xenotime.net>

From: Randy Dunlap <rdunlap@xenotime.net>

> So I think a better policy would be to emit a warning from within
> sysfs_remove_bin_file(), then return void.  The warning should include the
> stack trace and the filename (if possible).

Make sysfs_remove_bin_file() void.  If it detects an error,
printk the file name and call dump_stack().

sysfs_hash_and_remove() now returns an error code indicating
its success or failure so that sysfs_remove_bin_file() can
know success/failure.

Convert the only driver that checked the return value of
sysfs_remove_bin_file().

Signed-off-by: Randy Dunlap <rdunlap@xenotime.net>
---
 drivers/pci/hotplug/acpiphp_ibm.c |    4 +---
 fs/sysfs/bin.c                    |   13 ++++++++-----
 fs/sysfs/inode.c                  |   11 ++++++++---
 fs/sysfs/sysfs.h                  |    2 +-
 include/linux/sysfs.h             |    2 +-
 5 files changed, 19 insertions(+), 13 deletions(-)

--- linux-2618-rc1mm1.orig/fs/sysfs/bin.c
+++ linux-2618-rc1mm1/fs/sysfs/bin.c
@@ -10,6 +10,7 @@
 
 #include <linux/errno.h>
 #include <linux/fs.h>
+#include <linux/kernel.h>
 #include <linux/kobject.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -176,7 +177,6 @@ const struct file_operations bin_fops = 
  *	sysfs_create_bin_file - create binary file for object.
  *	@kobj:	object.
  *	@attr:	attribute descriptor.
- *
  */
 
 int sysfs_create_bin_file(struct kobject * kobj, struct bin_attribute * attr)
@@ -191,13 +191,16 @@ int sysfs_create_bin_file(struct kobject
  *	sysfs_remove_bin_file - remove binary file for object.
  *	@kobj:	object.
  *	@attr:	attribute descriptor.
- *
  */
 
-int sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
+void sysfs_remove_bin_file(struct kobject * kobj, struct bin_attribute * attr)
 {
-	sysfs_hash_and_remove(kobj->dentry,attr->attr.name);
-	return 0;
+	if (sysfs_hash_and_remove(kobj->dentry, attr->attr.name) < 0) {
+		printk(KERN_ERR "%s: "
+			"bad dentry or inode or no such file: \"%s\"\n",
+			__FUNCTION__, attr->attr.name);
+		dump_stack();
+	}
 }
 
 EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
--- linux-2618-rc1mm1.orig/fs/sysfs/inode.c
+++ linux-2618-rc1mm1/fs/sysfs/inode.c
@@ -12,6 +12,7 @@
 #include <linux/namei.h>
 #include <linux/backing-dev.h>
 #include <linux/capability.h>
+#include <linux/errno.h>
 #include "sysfs.h"
 
 extern struct super_block * sysfs_sb;
@@ -221,17 +222,18 @@ void sysfs_drop_dentry(struct sysfs_dire
 	}
 }
 
-void sysfs_hash_and_remove(struct dentry * dir, const char * name)
+int sysfs_hash_and_remove(struct dentry * dir, const char * name)
 {
 	struct sysfs_dirent * sd;
 	struct sysfs_dirent * parent_sd;
+	int found = 0;
 
 	if (!dir)
-		return;
+		return -ENOENT;
 
 	if (dir->d_inode == NULL)
 		/* no inode means this hasn't been made visible yet */
-		return;
+		return -ENOENT;
 
 	parent_sd = dir->d_fsdata;
 	mutex_lock(&dir->d_inode->i_mutex);
@@ -242,8 +244,11 @@ void sysfs_hash_and_remove(struct dentry
 			list_del_init(&sd->s_sibling);
 			sysfs_drop_dentry(sd, dir);
 			sysfs_put(sd);
+			found = 1;
 			break;
 		}
 	}
 	mutex_unlock(&dir->d_inode->i_mutex);
+
+	return found ? 0 : -ENOENT;
 }
--- linux-2618-rc1mm1.orig/fs/sysfs/sysfs.h
+++ linux-2618-rc1mm1/fs/sysfs/sysfs.h
@@ -10,7 +10,7 @@ extern int sysfs_make_dirent(struct sysf
 				umode_t, int);
 
 extern int sysfs_add_file(struct dentry *, const struct attribute *, int);
-extern void sysfs_hash_and_remove(struct dentry * dir, const char * name);
+extern int sysfs_hash_and_remove(struct dentry * dir, const char * name);
 extern struct sysfs_dirent *sysfs_find(struct sysfs_dirent *dir, const char * name);
 
 extern int sysfs_create_subdir(struct kobject *, const char *, struct dentry **);
--- linux-2618-rc1mm1.orig/include/linux/sysfs.h
+++ linux-2618-rc1mm1/include/linux/sysfs.h
@@ -116,7 +116,7 @@ sysfs_remove_link(struct kobject *, cons
 
 int __must_check sysfs_create_bin_file(struct kobject * kobj,
 					struct bin_attribute * attr);
-int __must_check sysfs_remove_bin_file(struct kobject * kobj,
+void sysfs_remove_bin_file(struct kobject * kobj,
 					struct bin_attribute * attr);
 
 int __must_check sysfs_create_group(struct kobject *,
--- linux-2618-rc1mm1.orig/drivers/pci/hotplug/acpiphp_ibm.c
+++ linux-2618-rc1mm1/drivers/pci/hotplug/acpiphp_ibm.c
@@ -487,9 +487,7 @@ static void __exit ibm_acpiphp_exit(void
 	if (ACPI_FAILURE(status))
 		err("%s: Notification handler removal failed\n", __FUNCTION__);
 	/* remove the /sys entries */
-	if (sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr))
-		err("%s: removal of sysfs file apci_table failed\n",
-				__FUNCTION__);
+	sysfs_remove_bin_file(sysdir, &ibm_apci_table_attr);
 }
 
 module_init(ibm_acpiphp_init);

  reply	other threads:[~2006-07-11  6:02 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-09  9:11 2.6.18-rc1-mm1 Andrew Morton
2006-07-09 10:20 ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 10:26 ` 2.6.18-rc1-mm1 Fabio Comolli
2006-07-09 10:45   ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-09 12:37     ` 2.6.18-rc1-mm1 Nick Piggin
2006-07-09 12:55       ` 2.6.18-rc1-mm1 Nick Piggin
2006-07-10  8:50       ` 2.6.18-rc1-mm1 Arjan van de Ven
2006-07-09 10:32 ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 10:33   ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 10:52   ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-09 21:06     ` 2.6.18-rc1-mm1 Arjan van de Ven
2006-07-10  7:40     ` 2.6.18-rc1-mm1 Ingo Molnar
2006-07-10  9:22       ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-10  9:25         ` 2.6.18-rc1-mm1 Ingo Molnar
2006-07-10 10:01           ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-10 10:37             ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-10 10:37               ` 2.6.18-rc1-mm1 Ingo Molnar
2006-07-10 10:57                 ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 11:02 ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 11:13   ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 12:10   ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-09 13:19     ` 2.6.18-rc1-mm1 Michal Piotrowski
2006-07-09 11:22 ` 2.6.18-rc1-mm1 Reuben Farrelly
2006-07-09 12:22   ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-09 12:56     ` 2.6.18-rc1-mm1 Alan Cox
2006-07-09 14:21       ` 2.6.18-rc1-mm1 Reuben Farrelly
2006-07-09 16:29       ` 2.6.18-rc1-mm1 Jeff Garzik
2006-07-09 18:35     ` 2.6.18-rc1-mm1 Andi Kleen
2006-07-11 19:37       ` 2.6.18-rc1-mm1 Greg KH
2006-07-09 21:10     ` 2.6.18-rc1-mm1 john stultz
2006-07-09 17:33   ` 2.6.18-rc1-mm1 Randy.Dunlap
2006-07-09 21:40     ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-10  4:56   ` 2.6.18-rc1-mm1 Randy.Dunlap
2006-07-10  5:01     ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-10  5:35   ` 2.6.18-rc1-mm1 Randy.Dunlap
2006-07-09 11:49 ` 2.6.18-rc1-mm1 fails on amd64 (smp_call_function_single) Gregoire Favre
2006-07-09 13:00   ` Adrian Bunk
2006-07-09 14:11     ` Gregoire Favre
2006-07-09 20:39   ` Rafael J. Wysocki
2006-07-09 21:03     ` Andrew Morton
2006-07-09 22:37       ` Rafael J. Wysocki
2006-07-09 22:44         ` Andrew Morton
2006-07-10  0:08           ` Andi Kleen
2006-07-09 12:46 ` modpost error about size inconsitency Sam Ravnborg
2006-07-09 12:49   ` Sam Ravnborg
2006-07-09 14:28 ` [-mm patch] fix MODULES=n compile Adrian Bunk
2006-07-09 14:28 ` [-mm patch] proper prototype for drivers/scsi/arcmsr/arcmsr_attr.c:arcmsr_free_sysfs_attr() Adrian Bunk
2006-07-09 16:19 ` 2.6.18-rc1-mm1 oops on x86_64 Cedric Le Goater
2006-07-09 20:21   ` Andrew Morton
2006-07-09 20:35     ` Rafael J. Wysocki
2006-07-09 20:59       ` Andrew Morton
2006-07-09 21:11         ` Rafael J. Wysocki
2006-07-10 15:54     ` Christoph Lameter
2006-07-10 17:22       ` Christoph Lameter
2006-07-10 16:20     ` Christoph Lameter
2006-07-10 17:38       ` Christoph Lameter
2006-07-10 20:27         ` Cedric Le Goater
2006-07-10 20:32           ` Rafael J. Wysocki
2006-07-09 17:28 ` 2.6.18-rc1-mm1 Dominik Karall
2006-07-09 20:24   ` 2.6.18-rc1-mm1 Andrew Morton
2006-07-10  7:11     ` 2.6.18-rc1-mm1 Mauro Carvalho Chehab
2006-07-10 22:25       ` 2.6.18-rc1-mm1 Dominik Karall
2006-07-13 22:10       ` 2.6.18-rc1-mm1 Dominik Karall
2006-07-09 17:53 ` [-mm patch] make arch/i386/kernel/cpu/cpufreq/longhaul.c:longhaul_walk_callback() static Adrian Bunk
2006-07-09 17:53 ` [-mm patch] kernel/rcutorture.c: make code static Adrian Bunk
2006-07-10 14:58   ` Paul E. McKenney
2006-07-09 18:22 ` 2.6.18-rc1-mm1: /sys/class/net/ethN becoming symlink befuddled /sbin/ifup Mike Galbraith
2006-07-09 19:01   ` Mike Galbraith
2006-07-09 20:51   ` Andrew Morton
2006-07-10  0:32     ` David Miller
2006-07-11 22:59       ` Greg KH
2006-07-12  6:29         ` Kay Sievers
2006-07-10  1:29     ` Jeremy Fitzhardinge
2006-07-10  5:01     ` Mike Galbraith
2006-07-09 19:24 ` 2.6.18-rc1-mm1 Valdis.Kletnieks
2006-07-09 21:11   ` 2.6.18-rc1-mm1 john stultz
2006-07-09 21:37 ` 2.6.18-rc1-mm1 inconsistent lock state in netpoll_send_skb Laurent Riffard
2006-07-10  8:40   ` Arjan van de Ven
2006-07-10 19:06     ` Laurent Riffard
2006-07-11  8:40       ` Arjan van de Ven
2006-07-11 22:00         ` Laurent Riffard
2006-07-09 21:47 ` 2.6.18-rc1-mm1 reiser4 module calls generic_file_read Laurent Riffard
2006-07-10 13:37   ` Edward Shishkin
2006-07-09 23:32 ` [-mm patch] fs/ocfs2/ioctl.c should #include "ioctl.h" Adrian Bunk
2006-07-10  0:33 ` 2.6.18-rc1-mm1 J.A. Magallón
2006-07-10 10:02   ` 2.6.18-rc1-mm1 Alan Cox
2006-07-10  1:10 ` 2.6.18-rc1-mm1 Brice Goglin
2006-07-10 15:22 ` 2.6.18-rc1-mm1 Rafael J. Wysocki
2006-07-10 18:33 ` [-mm patch] include/scsi/libsas.h should #include <linux/scatterlist.h> Adrian Bunk
2006-07-10 19:29 ` [PATCH -mm] sysfs_remove_bin_file: no return value, no check needed Randy.Dunlap
2006-07-10 21:43   ` Andrew Morton
2006-07-11  0:36     ` Randy.Dunlap
2006-07-11  6:05       ` Randy.Dunlap [this message]
2006-07-10 22:21 ` 2.6.18-rc1-mm1 J.A. Magallón
2006-07-11 12:47 ` [-mm patch] MICROCODE should select FW_LOADER Adrian Bunk
2006-07-11 12:52 ` 2.6.18-rc1-mm1: drivers/ide/pci/jmicron.c warning Adrian Bunk
2006-07-11 14:02   ` Alan Cox
2006-07-11 22:10     ` Adrian Bunk
2006-07-11 23:10       ` Alan Cox
2006-07-11 23:23         ` Andrew Morton
2006-07-11 23:27           ` Adrian Bunk
2006-07-12 20:45 ` 2.6.18-rc1-mm1 Reuben Farrelly
2006-07-13 20:18 ` [-mm patch] DEBUG_SHIRQ should depend on DEBUG_KERNEL Adrian Bunk
2006-07-15 13:41   ` Thomas Gleixner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060710230525.860d0caa.rdunlap@xenotime.net \
    --to=rdunlap@xenotime.net \
    --cc=akpm@osdl.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®