Skip to contentSkip to conversation

proc: use BUG_ON() in de_put()

PATCH In review Alexey Dobriyan 2 participants 3 messages Nov 15, 2007 – Nov 22, 2007 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: use BUG_ON() in de_put()

It's much more visible that some printk. I still has an unexplained oops in proc, so let's leave it for a while.

---

 fs/proc/inode.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
fs/proc/inode.c +1 -6
@@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
 {
 	if (de) {	
 		lock_kernel();		
-		if (!atomic_read(&de->count)) {
-			printk("de_put: entry %s already free!\n", de->name);
-			unlock_kernel();
-			return;
-		}
-
+		BUG_ON(atomic_read(&de->count) == 0);
 		if (atomic_dec_and_test(&de->count)) {
 			if (de->deleted) {
 				printk("de_put: deferred delete of %s\n",
#1 lore raw
Quoted 15 lines · On Thu, 15 Nov 2007 19:12:49 +0300 Alexey Dobriyan <[email protected]> wrote:

It's much more visible that some printk. I still has an unexplained oops in proc, so let's leave it for a while.

---

 fs/proc/inode.c |    7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
fs/proc/inode.c +0 -0
@@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
 {
 	if (de) {	
 		lock_kernel();		

fs/proc/inode.c void de_put(struct proc_dir_entry *de) · line 43

Quoted 10 lines
fs/proc/inode.c +1 -6
-		if (!atomic_read(&de->count)) {
-			printk("de_put: entry %s already free!\n", de->name);
-			unlock_kernel();
-			return;
-		}
-
+		BUG_ON(atomic_read(&de->count) == 0);
 		if (atomic_dec_and_test(&de->count)) {
 			if (de->deleted) {
 				printk("de_put: deferred delete of %s\n",

I don't see that an error in here _requires_ that we nuke the machine. Surely we can emit a warning and then recover in some fashion?

#2 lore raw
Quoted 17 lines · Andrew Morton
Quoted 14 lines · On Thu, 15 Nov 2007 19:12:49 +0300 Alexey Dobriyan <[email protected]> wrote:

It's much more visible that some printk. I still has an unexplained oops in proc, so let's leave it for a while.

fs/proc/inode.c +0 -5
@@ -37,12 +37,7 @@ void de_put(struct proc_dir_entry *de)
 {
 	if (de) {	
 		lock_kernel();		
-		if (!atomic_read(&de->count)) {
-			printk("de_put: entry %s already free!\n", de->name);
-			unlock_kernel();
-			return;
-		}
Quoted 8 lines

fs/proc/inode.c void de_put(struct proc_dir_entry *de) · line 43

Quoted 5 lines
fs/proc/inode.c +1 -1
-
+		BUG_ON(atomic_read(&de->count) == 0);
 		if (atomic_dec_and_test(&de->count)) {
 			if (de->deleted) {
 				printk("de_put: deferred delete of %s\n",

I don't see that an error in here _requires_ that we nuke the machine. Surely we can emit a warning and then recover in some fashion?

Hmm... atomic_dec_and_test() in -mm already has diagnostics¹ when doing 0 => -1 transition, google says this check triggered only once. I think we should just drop it.

¹ i386 only :^)