Skip to contentSkip to conversation

tracing: don't stuff stale pointers in filp->private_data

PATCH Dave Jones 3 participants 4 messages Sep 20, 2013 – Sep 25, 2013 Tracing

lore
Share & tools
lore

Dave Jones

author
#0 lore raw

Probably harmless, but still not a nice thing to do.

kernel/trace/trace_events.c +1 -0
index 368a4d5..75d3556 100644
@@ -1124,6 +1124,7 @@ static int system_tr_open(struct inode *inode, struct file *filp)
 	if (ret < 0) {
 		trace_array_put(tr);
 		kfree(dir);
+		dir = NULL;
 	}
 
 	filp->private_data = dir;
#1 lore raw
Quoted 9 lines · Dave Jones

Probably harmless, but still not a nice thing to do.

kernel/trace/trace_events.c +0 -0
index 368a4d5..75d3556 100644

kernel/trace/trace_events.c static int system_tr_open(struct inode *inode, struct file *filp) · line 1130

Quoted 7 lines
kernel/trace/trace_events.c +1 -0
@@ -1124,6 +1124,7 @@ static int system_tr_open(struct inode *inode, struct file *filp)
 	if (ret < 0) {
 		trace_array_put(tr);
 		kfree(dir);
+		dir = NULL;
 	}
 
 	filp->private_data = dir;

Er... Why not simply return ret; instead?

maintainer
#2 lore raw

Or make the assignment in an else block.

-- Steve

Quoted 21 lines · Al Viro

Review

Quoted 5 lines · Dave Jones

Probably harmless, but still not a nice thing to do.

(quoted diff) +0 -0

b/kernel/trace/trace_events.c

kernel/trace/trace_events.c static int system_tr_open(struct inode *inode,

Quoted 4 lines

index 368a4d5..75d3556 100644

kernel/trace/trace_events.c +0 -0
@@ -1124,6 +1124,7 @@ static int system_tr_open(struct inode *inode,

struct file *filp)

kernel/trace/trace_events.c static int system_tr_open(struct inode *inode, struct file *filp) · line 1130

Quoted 7 lines
kernel/trace/trace_events.c +1 -0
 	if (ret < 0) {
 		trace_array_put(tr);
 		kfree(dir);
+		dir = NULL;
 	}
 
 	filp->private_data = dir;

Er... Why not simply return ret; instead?

Signature · 1 line
Sent from my Android phone with K-9 Mail. Please excuse my brevity.
author
#3 lore raw

Probably harmless, but still not a nice thing to do.

kernel/trace/trace_events.c +2 -2
index 368a4d5..27aa16e 100644
@@ -1124,10 +1124,10 @@ static int system_tr_open(struct inode *inode, struct file *filp)
 	if (ret < 0) {
 		trace_array_put(tr);
 		kfree(dir);
+	} else {
+		filp->private_data = dir;
 	}
 
-	filp->private_data = dir;
-
 	return ret;
 }