Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1389358
| From | Steven Rostedt <rostedt@goodmis.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [for-next][PATCH 4/5] tracing: Handle tracing_map_alloc_elts() error path correctly |
| Date | 2016-04-27 18:40 +0200 |
| Message-ID | <rsAFl-4bo-41@gated-at.bofh.it> (permalink) |
| References | <rsAFk-4bo-9@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Tom Zanussi <tom.zanussi@linux.intel.com>
If tracing_map_elt_alloc() fails, it will return ERR_PTR() instead of
NULL, so change the check to IS_ERROR(). We also need to set the
failed entry in the map->elts array to NULL instead of ERR_PTR() so
tracing_map_free_elts() doesn't try freeing an ERR_PTR().
tracing_map_free_elts() should also zero out what it frees so a
reentrant call won't find previously freed elements.
Link: http://lkml.kernel.org/r/f29d03b00bce3aac8cf151a8a30e6c83e5fee66d.1461610073.git.tom.zanussi@linux.intel.com
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/tracing_map.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
index e7dfc5eec669..0a689bbb78ef 100644
--- a/kernel/trace/tracing_map.c
+++ b/kernel/trace/tracing_map.c
@@ -366,10 +366,13 @@ static void tracing_map_free_elts(struct tracing_map *map)
if (!map->elts)
return;
- for (i = 0; i < map->max_elts; i++)
+ for (i = 0; i < map->max_elts; i++) {
tracing_map_elt_free(*(TRACING_MAP_ELT(map->elts, i)));
+ *(TRACING_MAP_ELT(map->elts, i)) = NULL;
+ }
tracing_map_array_free(map->elts);
+ map->elts = NULL;
}
static int tracing_map_alloc_elts(struct tracing_map *map)
@@ -383,7 +386,8 @@ static int tracing_map_alloc_elts(struct tracing_map *map)
for (i = 0; i < map->max_elts; i++) {
*(TRACING_MAP_ELT(map->elts, i)) = tracing_map_elt_alloc(map);
- if (!(*(TRACING_MAP_ELT(map->elts, i)))) {
+ if (IS_ERR(*(TRACING_MAP_ELT(map->elts, i)))) {
+ *(TRACING_MAP_ELT(map->elts, i)) = NULL;
tracing_map_free_elts(map);
return -ENOMEM;
--
2.8.0.rc3
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[for-next][PATCH 0/5] tracing: More updates for 4.7 Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 3/5] tracing: Add check for NULL event field when creating hist field Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 5/5] tracing: Dont use the address of the buffer array name in copy_from_user Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 2/5] tracing: checking for NULL instead of IS_ERR() Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 4/5] tracing: Handle tracing_map_alloc_elts() error path correctly Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200 [for-next][PATCH 1/5] tracing: Do not inherit event-fork option for instances Steven Rostedt <rostedt@goodmis.org> - 2016-04-27 18:40 +0200
csiph-web