From patchwork Tue Sep 6 15:45:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 75559 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp615917qgf; Tue, 6 Sep 2016 08:45:25 -0700 (PDT) X-Received: by 10.66.251.33 with SMTP id zh1mr73211356pac.55.1473176725737; Tue, 06 Sep 2016 08:45:25 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b185si35905638pfa.125.2016.09.06.08.45.25; Tue, 06 Sep 2016 08:45:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755954AbcIFPpX (ORCPT + 27 others); Tue, 6 Sep 2016 11:45:23 -0400 Received: from mail-yw0-f170.google.com ([209.85.161.170]:33113 "EHLO mail-yw0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753790AbcIFPpV (ORCPT ); Tue, 6 Sep 2016 11:45:21 -0400 Received: by mail-yw0-f170.google.com with SMTP id l8so60605435ywb.0 for ; Tue, 06 Sep 2016 08:45:21 -0700 (PDT) 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) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id x64sm12333455ite.8.2016.09.06.08.45.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 06 Sep 2016 08:45:20 -0700 (PDT) From: Mathieu Poirier To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org Subject: [PATCH] coresight: perf: deal with error condition properly Date: Tue, 6 Sep 2016 09:45:18 -0600 Message-Id: <1473176718-1693-1-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- drivers/hwtracing/coresight/coresight-etm-perf.c | 4 ++-- drivers/hwtracing/coresight/coresight.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 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);