coresight: perf: deal with error condition properly
authorMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 24 Aug 2016 20:07:56 +0000 (14:07 -0600)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 6 Sep 2016 15:00:10 +0000 (09:00 -0600)
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>
drivers/hwtracing/coresight/coresight-etm-perf.c
drivers/hwtracing/coresight/coresight.c

index 98eb207684fa7d8b60b751745c074e58718c13ad..2cd7c718198a82e3a2aeecc5aed1c3a5643157d7 100644 (file)
@@ -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]);
        }
 
@@ -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;
        }
 
index fcbedd3905e36c5c4aa0b0ca8b073ab23419fca5..7bf00a0beb6f14b4c69cdaf619a2d981e58f612a 100644 (file)
@@ -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);
 
This page took 0.03636 seconds and 5 git commands to generate.