File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -341,8 +341,8 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
341
341
{
342
342
bool unaligned_chunks = mr -> flags & XDP_UMEM_UNALIGNED_CHUNK_FLAG ;
343
343
u32 chunk_size = mr -> chunk_size , headroom = mr -> headroom ;
344
+ u64 npgs , addr = mr -> addr , size = mr -> len ;
344
345
unsigned int chunks , chunks_per_page ;
345
- u64 addr = mr -> addr , size = mr -> len ;
346
346
int err ;
347
347
348
348
if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE ) {
@@ -372,6 +372,10 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
372
372
if ((addr + size ) < addr )
373
373
return - EINVAL ;
374
374
375
+ npgs = div_u64 (size , PAGE_SIZE );
376
+ if (npgs > U32_MAX )
377
+ return - EINVAL ;
378
+
375
379
chunks = (unsigned int )div_u64 (size , chunk_size );
376
380
if (chunks == 0 )
377
381
return - EINVAL ;
@@ -391,7 +395,7 @@ static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr)
391
395
umem -> size = size ;
392
396
umem -> headroom = headroom ;
393
397
umem -> chunk_size_nohr = chunk_size - headroom ;
394
- umem -> npgs = size / PAGE_SIZE ;
398
+ umem -> npgs = ( u32 ) npgs ;
395
399
umem -> pgs = NULL ;
396
400
umem -> user = NULL ;
397
401
umem -> flags = mr -> flags ;
You can’t perform that action at this time.
0 commit comments