diff mbox series

[v2,1/4] mkfs.xfs: avoid potential overflowing expression in xfs_mkfs.c

Message ID 20240613211933.1169581-2-bodonnel@redhat.com (mailing list archive)
State Superseded, archived
Headers show
Series xfsprogs: coverity fixes | expand

Commit Message

Bill O'Donnell June 13, 2024, 9:09 p.m. UTC
Cast max_tx_bytes to uint64_t to avoid overflowing expression in
calc_concurrency_logblocks().

Coverity-id: 1596603

Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>
---
 mkfs/xfs_mkfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Darrick J. Wong June 14, 2024, 3:50 a.m. UTC | #1
On Thu, Jun 13, 2024 at 04:09:15PM -0500, Bill O'Donnell wrote:
> Cast max_tx_bytes to uint64_t to avoid overflowing expression in
> calc_concurrency_logblocks().
> 
> Coverity-id: 1596603
> 
> Signed-off-by: Bill O'Donnell <bodonnel@redhat.com>

Looks ok,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>

(didn't hch rvb this earlier?)

--D

> ---
>  mkfs/xfs_mkfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index f4a9bf20..2f801dd4 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -3678,7 +3678,7 @@ calc_concurrency_logblocks(
>  	 * without blocking for space.  Increase the figure by 50% so that
>  	 * background threads can also run.
>  	 */
> -	log_bytes = max_tx_bytes * 3 * cli->log_concurrency / 2;
> +	log_bytes = (uint64_t)max_tx_bytes * 3 * cli->log_concurrency / 2;
>  	new_logblocks = min(XFS_MAX_LOG_BYTES >> cfg->blocklog,
>  				log_bytes >> cfg->blocklog);
>  
> -- 
> 2.45.2
> 
>
diff mbox series

Patch

diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index f4a9bf20..2f801dd4 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -3678,7 +3678,7 @@  calc_concurrency_logblocks(
 	 * without blocking for space.  Increase the figure by 50% so that
 	 * background threads can also run.
 	 */
-	log_bytes = max_tx_bytes * 3 * cli->log_concurrency / 2;
+	log_bytes = (uint64_t)max_tx_bytes * 3 * cli->log_concurrency / 2;
 	new_logblocks = min(XFS_MAX_LOG_BYTES >> cfg->blocklog,
 				log_bytes >> cfg->blocklog);