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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5A55BC77B75 for ; Fri, 21 Apr 2023 12:14:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1EOeEDRiPF+a4nOAV79WJdCLx5cdbvisHEZDgbXbE9E=; b=M6zJBhEFXP5kL6 5lEb95Nd6L7xIZQkim+yZHvLDvmH8sZY44+/kHiQRJ8fyMZlCEpsXtLYIJ0alGWR0w2UBFRansZ3x m0IQxnC+zyk/ssruNGiijSQGR1ipXh/sCLpOq4OTwEC/WhUFBQaJvD3MaB1AV5kVEgH0K+IODNpYb 5wFlkwj7QOy3hErRdLjwvywJPqtW6t1qQgUsnOswjzjTgztpQGAGFovnAnTU54b4JAknWCB98MhSj CxbLXFICoxVm/X3229VjDjWv3Gb4ot191JlTuG9VuJCQT97MDad1I+ntITLHNrwZQ+GnQuPyDVCIr v+TiWM9gQZByer6nX0dg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pppdK-00AphH-37; Fri, 21 Apr 2023 12:12:59 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pppdG-00Apgh-1C for linux-arm-kernel@lists.infradead.org; Fri, 21 Apr 2023 12:12:56 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4D07C1480; Fri, 21 Apr 2023 05:13:36 -0700 (PDT) Received: from [10.57.82.85] (unknown [10.57.82.85]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6EEA63F587; Fri, 21 Apr 2023 05:12:50 -0700 (PDT) Message-ID: Date: Fri, 21 Apr 2023 13:12:48 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet() To: Dan Carpenter Cc: Mike Leach , Leo Yan , Alexander Shishkin , Mathieu Poirier , Greg Kroah-Hartman , coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, kernel-janitors@vger.kernel.org References: <7d33e244-d8b9-4c27-9653-883a13534b01@kili.mountain> From: Suzuki K Poulose In-Reply-To: <7d33e244-d8b9-4c27-9653-883a13534b01@kili.mountain> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230421_051254_481908_DA7E35F6 X-CRM114-Status: GOOD ( 18.65 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Hi Dan On 21/04/2023 11:42, Dan Carpenter wrote: > This code generates a Smatch warning: > > drivers/hwtracing/coresight/coresight-tmc-etr.c:947 tmc_etr_buf_insert_barrier_packet() > error: uninitialized symbol 'bufp'. > > The problem is that if tmc_sg_table_get_data() returns -EINVAL, then > when we test if "len < CORESIGHT_BARRIER_PKT_SIZE", the negative "len" > value is type promoted to a high unsigned long value which is greater > than CORESIGHT_BARRIER_PKT_SIZE. Fix this bug by adding an explicit > check for error codes. > > Fixes: 75f4e3619fe2 ("coresight: tmc-etr: Add transparent buffer management") > Signed-off-by: Dan Carpenter > --- > drivers/hwtracing/coresight/coresight-tmc-etr.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/hwtracing/coresight/coresight-tmc-etr.c b/drivers/hwtracing/coresight/coresight-tmc-etr.c > index 918d461fcf4a..eaa296ced167 100644 > --- a/drivers/hwtracing/coresight/coresight-tmc-etr.c > +++ b/drivers/hwtracing/coresight/coresight-tmc-etr.c > @@ -942,7 +942,7 @@ tmc_etr_buf_insert_barrier_packet(struct etr_buf *etr_buf, u64 offset) > > len = tmc_etr_buf_get_data(etr_buf, offset, > CORESIGHT_BARRIER_PKT_SIZE, &bufp); > - if (WARN_ON(len < CORESIGHT_BARRIER_PKT_SIZE)) > + if (WARN_ON(len < 0 || len < CORESIGHT_BARRIER_PKT_SIZE)) > return -EINVAL; > coresight_insert_barrier_packet(bufp); > return offset + CORESIGHT_BARRIER_PKT_SIZE; Thanks for the fix, I will send this as fixes at 6.4-rc1, as I have already sent the PULL request for 6.4 Suzuki _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel