From 2b5e9d5cb61478253ad47e999bba205dbce74e92 Mon Sep 17 00:00:00 2001 From: Satyajit Desai Date: Fri, 21 Oct 2016 17:24:48 -0700 Subject: [PATCH] coresight: tmc: skip tmc read if mem allocaiton failed Add NULL pointer check to ensure that we do copy to user only when we were able to allocate memory for ETR. Change-Id: I09b4bc37617811fd4acd86a7e4f5ef91630675df Signed-off-by: Satyajit Desai --- drivers/hwtracing/coresight/coresight-tmc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tmc.c b/drivers/hwtracing/coresight/coresight-tmc.c index 306465ededf9..766b052ade1d 100644 --- a/drivers/hwtracing/coresight/coresight-tmc.c +++ b/drivers/hwtracing/coresight/coresight-tmc.c @@ -1143,6 +1143,12 @@ static int tmc_read_prepare(struct tmc_drvdata *drvdata) goto err; } + if (drvdata->config_type == TMC_CONFIG_TYPE_ETR && + drvdata->vaddr == NULL) { + ret = -ENOMEM; + goto err; + } + if (!drvdata->enable) goto out;