Skip to content

Commit

Permalink
coresight: perf: deal with error condition properly
Browse files Browse the repository at this point in the history
Function coresight_build_path() should return -ENOMEM when kzalloc
fails to allocated the requested memory.  That way callers can deal
with the error condition in a similar way.

Signed-off-by: Mathieu Poirier <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
mathieupoirier authored and gregkh committed Sep 9, 2016
1 parent 3ba1eb1 commit 8e67cdb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions drivers/hwtracing/coresight/coresight-etm-perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ static void free_event_data(struct work_struct *work)
}

for_each_cpu(cpu, mask) {
if (event_data->path[cpu])
if (!(IS_ERR_OR_NULL(event_data->path[cpu])))
coresight_release_path(event_data->path[cpu]);
}

Expand Down Expand Up @@ -220,7 +220,7 @@ static void *etm_setup_aux(int event_cpu, void **pages,
* referenced later when the path is actually needed.
*/
event_data->path[cpu] = coresight_build_path(csdev);
if (!event_data->path[cpu])
if (IS_ERR(event_data->path[cpu]))
goto err;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/hwtracing/coresight/coresight.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)

path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
if (!path)
return NULL;
return ERR_PTR(-ENOMEM);

INIT_LIST_HEAD(path);

Expand Down

0 comments on commit 8e67cdb

Please sign in to comment.