Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>, Leo Yan <leo.yan@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet()
Date: Fri, 21 Apr 2023 13:12:48 +0100	[thread overview]
Message-ID: <ac054e28-55fa-85c2-5865-3a44f8e7fa5e@arm.com> (raw)
In-Reply-To: <7d33e244-d8b9-4c27-9653-883a13534b01@kili.mountain>

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 <dan.carpenter@linaro.org>
> ---
>   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

      reply	other threads:[~2023-04-21 12:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-21 10:42 [PATCH] coresight: Fix signedness bug in tmc_etr_buf_insert_barrier_packet() Dan Carpenter
2023-04-21 12:12 ` Suzuki K Poulose [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ac054e28-55fa-85c2-5865-3a44f8e7fa5e@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=dan.carpenter@linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox