From patchwork Thu Sep 8 22:50:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 75837 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp64536qgf; Thu, 8 Sep 2016 15:51:19 -0700 (PDT) X-Received: by 10.98.156.212 with SMTP id u81mr789283pfk.44.1473375079127; Thu, 08 Sep 2016 15:51:19 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id gc14si401553pac.142.2016.09.08.15.51.18; Thu, 08 Sep 2016 15:51:19 -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 S1757572AbcIHWvI (ORCPT + 27 others); Thu, 8 Sep 2016 18:51:08 -0400 Received: from mail-oi0-f54.google.com ([209.85.218.54]:34768 "EHLO mail-oi0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753223AbcIHWuo (ORCPT ); Thu, 8 Sep 2016 18:50:44 -0400 Received: by mail-oi0-f54.google.com with SMTP id m11so98452071oif.1 for ; Thu, 08 Sep 2016 15:50:44 -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:in-reply-to:references; bh=h9nNZ9SKoPAdlgt4/OzbOr1JgQl4PnlOCCpDCGw4PfA=; b=PM5nix8DnYrTvidQoUNYYrV+dBY7zFGXqKU9CB4iNQxJ9Al4a/Jw/94mtMgfmKML/Y J03sFOv7g8sRO+wWbAcZWmfq1GoM1lw1RqanF5e5WzR5VJLx5UqDuwSMteuOmSI0WqPG vW5lurHb8aYmL0N1AzUOjI7Tnk1NE7AICiwLs= 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:in-reply-to :references; bh=h9nNZ9SKoPAdlgt4/OzbOr1JgQl4PnlOCCpDCGw4PfA=; b=UMMz8rRRxAy6Q/uQ9EaZ8z6UH/+veXetx1g4jyRspT1qN45TeA4czGzvFzb1uxiQkA rAheEZNFhvg/1vXHTvgGzWB6rHSXPfhvzTTtlgFLCmhei6NOCPx+1hNrdr74H2iAlyI+ ecFgkWqLQN9iQt5xSbWcPowM5xXpX/ll1mtq8g+JCGbsmoUW8FTIsXaXJW1QmvVqqw7V XvICc6I6knuOBCY2oag9F3epLAdnIrhiPtF10tb6jVLL8pc1rXvGxsqOvRdYBnfMIa4Q mlzyUNCGHD+xmjlr5b+0G86N46zMmZ9feZpSWiujVvp/5u5LDJ+27Bb2J0BgfRE8YNl8 S+Yg== X-Gm-Message-State: AE9vXwP5oi+Syq/X23YL4y+8D320gBgDqbxzYe5+4YM7VJ06kcFQfglvb6e9XV0ym7sUBzv0 X-Received: by 10.157.45.138 with SMTP id g10mr532507otb.88.1473375043505; Thu, 08 Sep 2016 15:50:43 -0700 (PDT) Received: from t430.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id 194sm169598itu.4.2016.09.08.15.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 08 Sep 2016 15:50:42 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] coresight: perf: deal with error condition properly Date: Thu, 8 Sep 2016 16:50:38 -0600 Message-Id: <1473375039-5783-2-git-send-email-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473375039-5783-1-git-send-email-mathieu.poirier@linaro.org> References: <1473375039-5783-1-git-send-email-mathieu.poirier@linaro.org> 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);