All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next] RDMA/umem: Silence build warning on i386 architecture
@ 2021-01-06 12:20 Leon Romanovsky
  2021-01-08 20:28 ` Jason Gunthorpe
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2021-01-06 12:20 UTC (permalink / raw)
  To: Doug Ledford, Jason Gunthorpe; +Cc: Leon Romanovsky, linux-rdma

From: Leon Romanovsky <leonro@nvidia.com>

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)'

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/core/umem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index 313fabb9f4a2..95be8cc75d2e 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -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;
 	}
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-next] RDMA/umem: Silence build warning on i386 architecture
  2021-01-06 12:20 [PATCH rdma-next] RDMA/umem: Silence build warning on i386 architecture Leon Romanovsky
@ 2021-01-08 20:28 ` Jason Gunthorpe
  2021-01-11  6:41   ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Gunthorpe @ 2021-01-08 20:28 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: Doug Ledford, Leon Romanovsky, linux-rdma

On Wed, Jan 06, 2021 at 02:20:47PM +0200, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH rdma-next] RDMA/umem: Silence build warning on i386 architecture
  2021-01-08 20:28 ` Jason Gunthorpe
@ 2021-01-11  6:41   ` Leon Romanovsky
  0 siblings, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2021-01-11  6:41 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: Doug Ledford, linux-rdma

On Fri, Jan 08, 2021 at 04:28:31PM -0400, Jason Gunthorpe wrote:
> On Wed, Jan 06, 2021 at 02:20:47PM +0200, Leon Romanovsky wrote:
> > From: Leon Romanovsky <leonro@nvidia.com>
> >
> > 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..

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

>
> Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-01-11  6:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-06 12:20 [PATCH rdma-next] RDMA/umem: Silence build warning on i386 architecture Leon Romanovsky
2021-01-08 20:28 ` Jason Gunthorpe
2021-01-11  6:41   ` Leon Romanovsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.