perf dso: prevent null dsos from being added
PATCH 1/1 perf dso: prevent null dsos from being added
When sorting the dso array we sometimes get a crash due to null comparisons in comparator functions. So prevent __dsos__add from adding null to the dso array to avoid out-of-memory related errors.
Signed-off-by Anubhav Shelat <[email protected]>
--- tools/perf/util/dsos.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/dsos.c +3 -0
@@ -196,6 +196,9 @@ static struct dso *__dsos__find_by_longname_id(struct dsos *dsos,int __dsos__add (struct dsos *dsos,struct dso *dso) { +if (!dso) +return -EINVAL ; +if (dsos->cnt == dsos->allocated) {unsigned int to_allocate =2 ;struct dso **temp;
Signature · 1 line
2.52.0
Quoted 6 lines · Anubhav Shelat
When sorting the dso array we sometimes get a crash due to null comparisons in comparator functions. So prevent
__dsos__addfrom adding null to the dso array to avoid out-of-memory related errors.Signed-off-by Anubhav Shelat <[email protected]>
Reviewed-by Ian Rogers <[email protected]>
Thanks!
Ian
Quoted 21 lines
--- tools/perf/util/dsos.c | 3 +++ 1 file changed, 3 insertions(+)tools/perf/util/dsos.c +3
-1@@ -196,6 +196,9 @@ static struct dso *__dsos__find_by_longname_id(struct dsos *dsos,int __dsos__add (struct dsos *dsos,struct dso *dso) { +if (!dso) +return -EINVAL ; +if (dsos->cnt == dsos->allocated) {unsigned int to_allocate =2 ;struct dso **temp; --2.52.0
Quoted 5 lines · Anubhav Shelat
When sorting the dso array we sometimes get a crash due to null comparisons in comparator functions. So prevent
__dsos__addfrom adding null to the dso array to avoid out-of-memory related errors.
Applied to perf-tools-next, thanks!
Best regards,
Namhyung