mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-03 07:38:10 +00:00
RDMA/umem: Avoid undefined behavior of rounddown_pow_of_two()
[ Upstream commitb79f2dc5ff
] rounddown_pow_of_two() is undefined when the input is 0. Therefore we need to avoid it in ib_umem_find_best_pgsz and return 0. Otherwise, it could result in not rejecting an invalid page size which eventually causes a kernel oops due to the logical inconsistency. Fixes:3361c29e92
("RDMA/umem: Use simpler logic for ib_umem_find_best_pgsz()") Link: https://lore.kernel.org/r/20210113121703.559778-2-leon@kernel.org Signed-off-by: Aharon Landau <aharonl@nvidia.com> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Reviewed-by: Maor Gottlieb <maorg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
eb8ca93e49
commit
56c1362981
1 changed files with 1 additions and 1 deletions
|
@ -126,7 +126,7 @@ unsigned long ib_umem_find_best_pgsz(struct ib_umem *umem,
|
|||
*/
|
||||
if (mask)
|
||||
pgsz_bitmap &= GENMASK(count_trailing_zeros(mask), 0);
|
||||
return rounddown_pow_of_two(pgsz_bitmap);
|
||||
return pgsz_bitmap ? rounddown_pow_of_two(pgsz_bitmap) : 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ib_umem_find_best_pgsz);
|
||||
|
||||
|
|
Loading…
Reference in a new issue