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 <nicolinc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2105445
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Ashish Mhetre <amhetre@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nicolin Chen
2019-04-25 16:36:33 -07:00
committed by Laxman Dewangan
parent 6f325d969e
commit 9ca6957981

View File

@@ -1,7 +1,7 @@
/* /*
* mods_dmabuf.c - This file is part of NVIDIA MODS kernel driver. * 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 * NVIDIA MODS kernel driver is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License, * 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; u64 total_size = 0;
u32 total_segments = 0; u32 total_segments = 0;
phys_addr_t physical_address = 0; phys_addr_t physical_address = 0;
unsigned int segment_size = 0; u64 segment_size = 0;
struct scatterlist *sg; struct scatterlist *sg;
unsigned int sg_index; unsigned int sg_index;