From 9ca69579818f324dd85fe0ef838d63696aa413d2 Mon Sep 17 00:00:00 2001 From: Nicolin Chen Date: Thu, 25 Apr 2019 16:36:33 -0700 Subject: [PATCH] misc: mods: Fix segment_size overflow bug The sg->length may happen to be a large size, and this will overflow the local segment_size when accumulating sg->length to it at line "segment_size += sg->length". Since segment_size of MODS_DMABUF_GET_PHYSICAL_ADDRESS structure is defined in u64 type, this patch fixes the bug by changing the local varible to u64 as well. Bug 2521255 Change-Id: Id1fb6d149f55f4fd9238a399393ed2efae77c84a Signed-off-by: Nicolin Chen Reviewed-on: https://git-master.nvidia.com/r/2105445 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Ashish Mhetre GVS: Gerrit_Virtual_Submit Reviewed-by: Sachin Nikam Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/misc/mods/mods_dmabuf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mods/mods_dmabuf.c b/drivers/misc/mods/mods_dmabuf.c index 173dc043..9208e3e6 100644 --- a/drivers/misc/mods/mods_dmabuf.c +++ b/drivers/misc/mods/mods_dmabuf.c @@ -1,7 +1,7 @@ /* * mods_dmabuf.c - This file is part of NVIDIA MODS kernel driver. * - * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2014-2019, NVIDIA CORPORATION. All rights reserved. * * NVIDIA MODS kernel driver is free software: you can redistribute it and/or * modify it under the terms of the GNU General Public License, @@ -48,7 +48,7 @@ int esc_mods_dmabuf_get_phys_addr(struct file *filp, u64 total_size = 0; u32 total_segments = 0; phys_addr_t physical_address = 0; - unsigned int segment_size = 0; + u64 segment_size = 0; struct scatterlist *sg; unsigned int sg_index;