Skip to content

Commit

Permalink
Fixed a bug in gdr_generate_mr_handle
Browse files Browse the repository at this point in the history
  • Loading branch information
pakmarkthub committed Mar 6, 2023
1 parent 1ffe414 commit 604d68c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/gdrdrv/gdrdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@ MODULE_PARM_DESC(info_enabled, "enable info tracing");
#define GPU_PAGE_MASK (~GPU_PAGE_OFFSET)

#ifndef MAX
#define MAX(a,b) ((a) > (b) ? a : b)
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif

#ifndef MIN
#define MIN(a,b) ((a) < (b) ? a : b)
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#endif


Expand Down Expand Up @@ -596,7 +596,7 @@ static inline int gdr_generate_mr_handle(gdr_info_t *info, gdr_mr_t *mr)
if (unlikely(info->next_handle_overflow))
return -1;

next_handle = info->next_handle + (mr->mapped_size >> PAGE_SHIFT);
next_handle = info->next_handle + MAX(1, mr->mapped_size >> PAGE_SHIFT);

// The next handle will be overflowed, so we mark it.
if (unlikely((next_handle & ((gdr_hnd_t)(-1) >> PAGE_SHIFT)) < info->next_handle))
Expand Down

0 comments on commit 604d68c

Please sign in to comment.