Skip to contentSkip to conversation

tracing: Do not call kmem_cache_free() on allocation failure

PATCH In review Namhyung Kim 2 participants 2 messages Jun 7, 2013 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Do not call kmem_cache_free() on allocation failure

From: Namhyung Kim <[email protected]>

There's no point calling it when _alloc() failed.

---
 kernel/trace/trace_events.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/trace/trace_events.c +1 -6
index 27963e2bf4bf..bb4950b552b5 100644
@@ -97,7 +97,7 @@ static int __trace_define_field(struct list_head *head, const char *type,
 
 	field = kmem_cache_alloc(field_cachep, GFP_TRACE);
 	if (!field)
-		goto err;
+		return -ENOMEM;
 
 	field->name = name;
 	field->type = type;
@@ -114,11 +114,6 @@ static int __trace_define_field(struct list_head *head, const char *type,
 	list_add(&field->link, head);
 
 	return 0;
-
-err:
-	kmem_cache_free(field_cachep, field);
-
-	return -ENOMEM;
 }
 
 int trace_define_field(struct ftrace_event_call *call, const char *type,
Signature · 1 line
1.7.11.7
maintainer
#1 lore raw
Quoted 3 lines · Namhyung Kim

From: Namhyung Kim <[email protected]>

There's no point calling it when _alloc() failed.

Thanks, I queued this up for 3.11 as it's not that important for a late -rc release.

-- Steve

Quoted 31 lines
---
 kernel/trace/trace_events.c | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)
kernel/trace/trace_events.c +1 -6
index 27963e2bf4bf..bb4950b552b5 100644
@@ -97,7 +97,7 @@ static int __trace_define_field(struct list_head *head, const char *type,
 
 	field = kmem_cache_alloc(field_cachep, GFP_TRACE);
 	if (!field)
-		goto err;
+		return -ENOMEM;
 
 	field->name = name;
 	field->type = type;
@@ -114,11 +114,6 @@ static int __trace_define_field(struct list_head *head, const char *type,
 	list_add(&field->link, head);
 
 	return 0;
-
-err:
-	kmem_cache_free(field_cachep, field);
-
-	return -ENOMEM;
 }
 
 int trace_define_field(struct ftrace_event_call *call, const char *type,