
< 			upper = kmemdup(&entry[max + 1],
---
> 			unsigned long safe_index = (max + 1 < mas.last) ? max + 1 : max;
> 			upper = kmemdup(&entry[safe_index],
