Re: [PATCH] swiotlb: avoid potential left shift overflow

From: Christoph Hellwig
Date: Sat Aug 06 2022 - 04:30:14 EST


On Fri, Aug 05, 2022 at 07:44:38PM +0800, Chao Gao wrote:
> The second operand passed to slot_addr() is declared as int or unsigned int
> in all call sites. The left-shift to get the offset of a slot can overflow
> if swiotlb size is larger than 4G.
>
> Fixes: 26a7e094783d ("swiotlb: refactor swiotlb_tbl_map_single")
> Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx>

Can you just convert it to an inline function? That will take care
of the typing in a much cleaner way than a cast.