From patchwork Fri Sep 9 10:18:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 75863 Delivered-To: patch@linaro.org Received: by 10.140.106.11 with SMTP id d11csp266756qgf; Fri, 9 Sep 2016 03:19:18 -0700 (PDT) X-Received: by 10.66.62.164 with SMTP id z4mr5050927par.156.1473416344418; Fri, 09 Sep 2016 03:19:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d63si3328277pfc.34.2016.09.09.03.19.04; Fri, 09 Sep 2016 03:19:04 -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 S1754407AbcIIKS6 (ORCPT + 27 others); Fri, 9 Sep 2016 06:18:58 -0400 Received: from mail-pf0-f171.google.com ([209.85.192.171]:33577 "EHLO mail-pf0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754303AbcIIKSz (ORCPT ); Fri, 9 Sep 2016 06:18:55 -0400 Received: by mail-pf0-f171.google.com with SMTP id g202so28307737pfb.0 for ; Fri, 09 Sep 2016 03:18:55 -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=TXjQ2ppzyfddIfh4j9cQn+OI4R0E8PdZRc1tF1t1huk=; b=cM3B1FiMVHfrNFmrUF6ybw89hxE5fB/OHp99yGv6qZfz3nU/pP5RbYo9JsAw+UIQer AEsRatKAIo5wu1UL06b5/smafqOSJShlB4HCuhNloWOXXHKjwBTglH/e0HT+lVi2tnEE b+x6E9Prv6R8dgwhRQUdPYyrs828lfPD/6j/w= 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=TXjQ2ppzyfddIfh4j9cQn+OI4R0E8PdZRc1tF1t1huk=; b=juxp+vuAsSOaCGgbnNdIWaPAxDjW4Fd0aOVlv04V9B4xZqKvQLtQcEkUJaX2IaONEO zvAtL57i/eomCLgpWtDLR1s74V0km/ZErn2v2uYozvAXdsHJHwLCo1hU17yd3Q3Z0XQf EtNoDdNWJIF/L0qmd13iXDMA7/WDdRVYopJKFs/UoLmN7nDShQB6LqlThk3PbeL7eP/G Mst7wZZT4H4pzh+a9GutIDmmk+SxgFd+ecHom/VS6LsIUE1fy14IzpBhFo+vTr4G72pM 1totum4oF6bTKAVQgtHnvEF7gaRw1pK2nYJq9jthpRl0vqV1iw613rLnraanM/IAoe5J W53Q== X-Gm-Message-State: AE9vXwN+p9zez6ZkFlNX0WTBm3aAO6IhPhSMp5uxYTaEd4gk2NDJQXlypOMtJhJM2mnlycPE X-Received: by 10.98.46.199 with SMTP id u190mr5067130pfu.160.1473416334830; Fri, 09 Sep 2016 03:18:54 -0700 (PDT) Received: from ubuntu16.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id y3sm4117256pfy.36.2016.09.09.03.18.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Sep 2016 03:18:54 -0700 (PDT) From: Chunyan Zhang To: mathieu.poirier@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, zhang.lyra@gmail.com Subject: [PATCH] coresight: stm: return error code instead of zero in .packet() to avoid dead loop Date: Fri, 9 Sep 2016 18:18:09 +0800 Message-Id: <1473416289-30882-1-git-send-email-zhang.chunyan@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 In STM framework driver, the trace data writing loop would keep running until it received a negative return value or the whole trace packet has been written to STM device. So if the .packet() of STM device always returns zero since the device is not enabled or the parameter isn't supported, STM framework driver will stall into a dead loop. Returning -EACCES (Permission denied) in .packet() if the device is disabled makes more sense, and this is the same for returning -EINVAL if the channel passed into is not supported. Signed-off-by: Chunyan Zhang --- drivers/hwtracing/coresight/coresight-stm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/hwtracing/coresight/coresight-stm.c b/drivers/hwtracing/coresight/coresight-stm.c index 73be58a..6291ce1 100644 --- a/drivers/hwtracing/coresight/coresight-stm.c +++ b/drivers/hwtracing/coresight/coresight-stm.c @@ -399,10 +399,10 @@ static ssize_t stm_generic_packet(struct stm_data *stm_data, struct stm_drvdata, stm); if (!(drvdata && local_read(&drvdata->mode))) - return 0; + return -EACCES; if (channel >= drvdata->numsp) - return 0; + return -EINVAL; ch_addr = (unsigned long)stm_channel_addr(drvdata, channel);