mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-11-30 15:53:22 -05:00
spi: Fix invalid sgs value
[ Upstream commit 1a4e53d2fc4f68aa654ad96d13ad042e1a8e8a7d ] max_seg_size is unsigned int and it can have a value up to 2^32 (for eg:-RZ_DMAC driver sets dma_set_max_seg_size as U32_MAX) When this value is used in min_t() as an integer type, it becomes -1 and the value of sgs becomes 0. Fix this issue by replacing the 'int' data type with 'unsigned int' in min_t(). Signed-off-by: Biju Das <[email protected]> Reviewed-by: Lad Prabhakar <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
96f9c386fe
commit
e62e6c2d7a
1 changed files with 2 additions and 2 deletions
|
|
@ -844,10 +844,10 @@ int spi_map_buf(struct spi_controller *ctlr, struct device *dev,
|
|||
int i, ret;
|
||||
|
||||
if (vmalloced_buf || kmap_buf) {
|
||||
desc_len = min_t(int, max_seg_size, PAGE_SIZE);
|
||||
desc_len = min_t(unsigned int, max_seg_size, PAGE_SIZE);
|
||||
sgs = DIV_ROUND_UP(len + offset_in_page(buf), desc_len);
|
||||
} else if (virt_addr_valid(buf)) {
|
||||
desc_len = min_t(int, max_seg_size, ctlr->max_dma_len);
|
||||
desc_len = min_t(unsigned int, max_seg_size, ctlr->max_dma_len);
|
||||
sgs = DIV_ROUND_UP(len, desc_len);
|
||||
} else {
|
||||
return -EINVAL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue