mirror of https://gitee.com/openkylin/linux.git
coresight: perf: deal with error condition properly
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 <mathieu.poirier@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3ba1eb17b6
commit
8e67cdbc2f
|
@ -135,7 +135,7 @@ static void free_event_data(struct work_struct *work)
|
||||||
}
|
}
|
||||||
|
|
||||||
for_each_cpu(cpu, mask) {
|
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]);
|
coresight_release_path(event_data->path[cpu]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static void *etm_setup_aux(int event_cpu, void **pages,
|
||||||
* referenced later when the path is actually needed.
|
* referenced later when the path is actually needed.
|
||||||
*/
|
*/
|
||||||
event_data->path[cpu] = coresight_build_path(csdev);
|
event_data->path[cpu] = coresight_build_path(csdev);
|
||||||
if (!event_data->path[cpu])
|
if (IS_ERR(event_data->path[cpu]))
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -429,7 +429,7 @@ struct list_head *coresight_build_path(struct coresight_device *csdev)
|
||||||
|
|
||||||
path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
|
path = kzalloc(sizeof(struct list_head), GFP_KERNEL);
|
||||||
if (!path)
|
if (!path)
|
||||||
return NULL;
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
INIT_LIST_HEAD(path);
|
INIT_LIST_HEAD(path);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue