Skip to contentSkip to conversation

RDMA/umem: Silence build warning on i386 architecture

PATCH In review Leon Romanovsky 2 participants 3 messages Jan 6, 2021 – Jan 11, 2021 InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 RDMA/umem: Silence build warning on i386 architecture

From: Leon Romanovsky <[email protected]>

Sacrifice one page in order to silence compilation failure on i386 architecture.

drivers/infiniband/core/umem.c:205 __ib_umem_get() warn: impossible

			condition '(npages > (~0)) => (0-u32max > u32max)'
---
 drivers/infiniband/core/umem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/umem.c +1 -1
index 313fabb9f4a2..95be8cc75d2e 100644
@@ -202,7 +202,7 @@ static struct ib_umem *__ib_umem_get(struct ib_device *device,
 	}
 
 	npages = ib_umem_num_pages(umem);
-	if (npages == 0 || npages > UINT_MAX) {
+	if (npages == 0 || npages >= UINT_MAX) {
 		ret = -EINVAL;
 		goto out;
 	}
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 7 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Sacrifice one page in order to silence compilation failure on i386 architecture.

drivers/infiniband/core/umem.c:205 __ib_umem_get() warn: impossible

			condition '(npages > (~0)) => (0-u32max > u32max)'

I think I prefer to just leave this warning on 32 bit builds.. 32 bit inherently can't have this overflow so yes the condition should be impossible

Using >= is just confusing

If you really want to fix it then npages and every place that touches it should be made size_t or unsigned long.

This includes __sg_alloc_table_from_pages, which doesn't look so bad actually..

Jason

#2 lore raw
Quoted 13 lines · Jason Gunthorpe
Quoted 7 lines · Leon Romanovsky

From: Leon Romanovsky <[email protected]>

Sacrifice one page in order to silence compilation failure on i386 architecture.

drivers/infiniband/core/umem.c:205 __ib_umem_get() warn: impossible

			condition '(npages > (~0)) => (0-u32max > u32max)'

I think I prefer to just leave this warning on 32 bit builds.. 32 bit inherently can't have this overflow so yes the condition should be impossible

Quoted 7 lines

Using >= is just confusing

If you really want to fix it then npages and every place that touches it should be made size_t or unsigned long.

This includes __sg_alloc_table_from_pages, which doesn't look so bad actually..

npages is used as "unsigned long" in all places: pin_user_pages_fast() and internally in __sg_alloc_table_from_pages().

I can't say if it is going to be not bad as you said.

However, let's add rewrite of this patch to my backlog.

Thanks

Quoted 2 lines

Jason