From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B864AC43461 for ; Wed, 16 Sep 2020 08:06:53 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4751921973 for ; Wed, 16 Sep 2020 08:06:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pILKXo5q" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4751921973 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=z0ORGfXi7c2WLdWMm/ynfeD12aFIA4NVCakrdQHbZEM=; b=pILKXo5qDVvDJ13ZI95lTRoN/ k+xI85nUpG/BKrj37nPF5Zij2mcyWggM5ca4uo7Z2RyEHC//7fpQbJuNkNWyK8khWbvfqfYKEv6+C lBTIo98KN/6paOVcZyT9IzhoBqtoSDHzxZ5F1H/b8dZ30gvqQZSjMTo4/8E9DNSTEMZNxOU0BWVe3 kg99D+4RPRFVk0NUm2IjyFQDe1azWIeFWFwycUzk2gCk/BjLVJBWYfMF0ghBkDT7RFU2wWFUTltJI Ps5tGA854e3Ev1M80Dgcye6CwyoKxKqMj9Cu89fyJhWldvmgioo7YtMFnTsG2WpqDEeAIQC9g9eIp /u2qhIirQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kISRX-0005Pw-7Z; Wed, 16 Sep 2020 08:05:31 +0000 Received: from szxga06-in.huawei.com ([45.249.212.32] helo=huawei.com) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kISRT-0005Nl-6B for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 08:05:29 +0000 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id CD425B4BCD1EA4A3F0A8; Wed, 16 Sep 2020 16:05:12 +0800 (CST) Received: from [10.67.76.227] (10.67.76.227) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Wed, 16 Sep 2020 16:05:04 +0800 Subject: Re: [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface To: Mathieu Poirier References: <1600138437-61070-1-git-send-email-jonathan.zhouwen@huawei.com> <20200915164248.GA3641338@xps15> From: Jonathan Zhou Message-ID: <3f97b4a2-32b2-612e-7fc3-e4e8d6554c09@huawei.com> Date: Wed, 16 Sep 2020 16:05:04 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <20200915164248.GA3641338@xps15> Content-Language: en-GB X-Originating-IP: [10.67.76.227] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_040527_925312_E17F32B4 X-CRM114-Status: GOOD ( 18.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Shaokun Zhang , lizixian@hisilicon.com, Mike Leach , linux-arm-kernel@lists.infradead.org, Suzuki K Poulose Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 16/09/2020 00:42, Mathieu Poirier wrote: > On Tue, Sep 15, 2020 at 10:53:57AM +0800, Jonathan Zhou wrote: >> The member @nr_resource represents how many resource selector pairs, >> and the pair 0 is always implemented and reserved. >> So let's multiply by 2 when resetting the seletor configuration. >> And also update the validation of the input @idx. >> >> Cc: Mathieu Poirier >> Cc: Suzuki K Poulose >> Cc: Mike Leach >> Cc: Shaokun Zhang >> Cc: lizixian@hisilicon.com >> Signed-off-by: Jonathan Zhou >> --- >> ChangeLog in v2: >> * Address Mathieu's comments. >> >> drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 9 ++++++--- >> 1 file changed, 6 insertions(+), 3 deletions(-) > > You send me two identical patches on the same day - the only difference was the > RESEND had an capital 'f' in "Fix". That's the one I applied. > Very sorry for sending this patch twice. I saw your revise for my previous patch, so I am trying to keep the latter patches in line with the norms. Regards. Jonathan > Thanks, > Mathieu > > >> >> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c >> index b673e738bc9a..e4f1f659000d 100644 >> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c >> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c >> @@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev, >> } >> >> config->res_idx = 0x0; >> - for (i = 0; i < drvdata->nr_resource; i++) >> + for (i = 2; i < 2 * drvdata->nr_resource; i++) >> config->res_ctrl[i] = 0x0; >> >> config->ss_idx = 0x0; >> @@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev, >> >> if (kstrtoul(buf, 16, &val)) >> return -EINVAL; >> - /* Resource selector pair 0 is always implemented and reserved */ >> - if ((val == 0) || (val >= drvdata->nr_resource)) >> + /* >> + * Resource selector pair 0 is always implemented and reserved, >> + * namely an idx with 0 and 1 is illegal. >> + */ >> + if ((val < 2) || (val >= 2 * drvdata->nr_resource)) >> return -EINVAL; >> >> /* >> -- >> 1.9.1 >> > . > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel