Use bitmap_zalloc()/bitmap_free() instead of hand-writing them. It is less verbose and it improves the semantic. Signed-off-by: Christophe JAILLET <christophe.jaillet@xxxxxxxxxx> --- Out of curiosity, is it normal to have __free_page() in the error handling path of __create_xol_area() and put_page() in uprobe_clear_state()? uprobe_clear_state() seems to release the resources allocated in __create_xol_area(), but the implementation of __free_page() and of put_page() look quite different. This is maybe perfectly correct, but looks odd to me. --- kernel/events/uprobes.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 401bc2d24ce0..83fb62eed9c6 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -1485,8 +1485,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) if (unlikely(!area)) goto out; - area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long), - GFP_KERNEL); + area->bitmap = bitmap_zalloc(UINSNS_PER_PAGE, GFP_KERNEL); if (!area->bitmap) goto free_area; @@ -1510,7 +1509,7 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) __free_page(area->pages[0]); free_bitmap: - kfree(area->bitmap); + bitmap_free(area->bitmap); free_area: kfree(area); out: @@ -1551,7 +1550,7 @@ void uprobe_clear_state(struct mm_struct *mm) return; put_page(area->pages[0]); - kfree(area->bitmap); + bitmap_free(area->bitmap); kfree(area); } -- 2.34.1