lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <787bb77f-4271-43bc-96bd-4e22895d761b@linuxfoundation.org>
Date: Thu, 6 Nov 2025 15:11:43 -0700
From: Shuah Khan <skhan@...uxfoundation.org>
To: Zhang Chujun <zhangchujun@...s.chinamobile.com>,
 linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org
Cc: Shuah Khan <skhan@...uxfoundation.org>
Subject: Re: [PATCH] selftests/dma: fix invalid array access in printf

On 11/3/25 19:52, Zhang Chujun wrote:
> The printf statement attempts to print the DMA direction string using
> the syntax 'dir[directions]', which is an invalid array access. The
> variable 'dir' is an integer, and 'directions' is a char pointer array.
> This incorrect syntax should be 'directions[dir]', using 'dir' as the
> index into the 'directions' array. Fix this by correcting the array
> access from 'dir[directions]' to 'directions[dir]'.

How did you find this problem? The patch looks good to me, but
I do want to know how you found this because compiler doesn't
complain and I can build this fine.> 
> Signed-off-by: Zhang Chujun <zhangchujun@...s.chinamobile.com>
> 
> diff --git a/tools/testing/selftests/dma/dma_map_benchmark.c b/tools/testing/selftests/dma/dma_map_benchmark.c
> index b12f1f9babf8..b925756373ce 100644
> --- a/tools/testing/selftests/dma/dma_map_benchmark.c
> +++ b/tools/testing/selftests/dma/dma_map_benchmark.c
> @@ -118,7 +118,7 @@ int main(int argc, char **argv)
>   	}
>   
>   	printf("dma mapping benchmark: threads:%d seconds:%d node:%d dir:%s granule: %d\n",
> -			threads, seconds, node, dir[directions], granule);
> +			threads, seconds, node, directions[dir], granule);
>   	printf("average map latency(us):%.1f standard deviation:%.1f\n",
>   			map.avg_map_100ns/10.0, map.map_stddev/10.0);
>   	printf("average unmap latency(us):%.1f standard deviation:%.1f\n",
thanks,
-- Shuah


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ