Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1477562

[PATCH] coresight: perf: deal with error condition properly

Path csiph.com!news.mixmin.net!aioe.org!bofh.it!news.nic.it!robomod
From Mathieu Poirier <mathieu.poirier@linaro.org>
Newsgroups linux.kernel
Subject [PATCH] coresight: perf: deal with error condition properly
Date Tue, 06 Sep 2016 17:50:01 +0200
Message-ID <seqNj-3PR-13@gated-at.bofh.it> (permalink)
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=h9nNZ9SKoPAdlgt4/OzbOr1JgQl4PnlOCCpDCGw4PfA=; b=GQ2Qf4gWAchjHUMH8+2q0p1hZJgMcZY6+oMI8CCvt/lkt9Suqkx7Y79OE1kNoaUoVQ JhhC67NpwNePNNcm2yMjtHke/Y9ruuETihG+2PS32ywjzBNHhefAv0r2wkS2L1E2O6DA HLhKPl/NhMI2zyGXQhW00aFiBnpZgyM1sb6PM=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=h9nNZ9SKoPAdlgt4/OzbOr1JgQl4PnlOCCpDCGw4PfA=; b=kH0T+WQhWH0npt5Nnw0oxBmyKyqhbmBZJnsvM5oclv/zw4Fr5wJ5QeoTdEQOyzgphC K/V09QdQ/oLGu2k+G1EIrDHA0uVHfx8DkyP9eAvrHT9z/Nt+5gwnq8MEy3/N7/TIatSM ueCrOF0a18okizauIA3ekn3TxzK8obyYjLOiVp+Yijodl1+qTSdM3L5SRhrvbi2sNeHK 24YvDMkYHhcubXx0uhM/BO2um/iR0e/FJwZu3jtesn718NuDLlMrqcCHrO4K7We+B5uN GE0SfwsGOIGxvfKXJHDnZWhTdJX/WNmXhMoaSm0ElcVQ69uLKL+n8eHkL0NdC/WNO3Hj 6Tvg==
X-Gm-Message-State AE9vXwNKPu1jJBP61ReWta9zCoM0yc0lumXe9RUwu33rfi1Ohs8fkoCRP2OGqSJKcBSNZmzO
X-Received by 10.36.222.137 with SMTP id d131mr30619947itg.1.1473176720893; Tue, 06 Sep 2016 08:45:20 -0700 (PDT)
X-Mailer git-send-email 2.7.4
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 47
Organization linux.* mail to news gateway
X-Original-Cc linux-kernel@vger.kernel.org
X-Original-Date Tue, 6 Sep 2016 09:45:18 -0600
X-Original-Message-ID <1473176718-1693-1-git-send-email-mathieu.poirier@linaro.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1477562

Show key headers only | View raw


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 | 4 ++--
 drivers/hwtracing/coresight/coresight.c          | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-etm-perf.c b/drivers/hwtracing/coresight/coresight-etm-perf.c
index 98eb207684fa..2cd7c718198a 100644
--- a/drivers/hwtracing/coresight/coresight-etm-perf.c
+++ b/drivers/hwtracing/coresight/coresight-etm-perf.c
@@ -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;
 	}
 
diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c
index fcbedd3905e3..7bf00a0beb6f 100644
--- a/drivers/hwtracing/coresight/coresight.c
+++ b/drivers/hwtracing/coresight/coresight.c
@@ -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);
 
-- 
2.7.4

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH] coresight: perf: deal with error condition properly Mathieu Poirier <mathieu.poirier@linaro.org> - 2016-09-06 17:50 +0200

csiph-web