From: Andy Shevchenko Date: Tue, 14 May 2019 22:44:52 +0000 (-0700) Subject: kernel/sysctl.c: switch to bitmap_zalloc() X-Git-Tag: v5.15~6360^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=475dae385497dde3f25271ce77b526a1e54a472a;p=platform%2Fkernel%2Flinux-starfive.git kernel/sysctl.c: switch to bitmap_zalloc() Switch to bitmap_zalloc() to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *. Link: http://lkml.kernel.org/r/20190304094037.57756-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko Acked-by: Kees Cook Reviewed-by: Andrew Morton Cc: Luis Chamberlain Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/kernel/sysctl.c b/kernel/sysctl.c index ba158f6..d82f916 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -3178,9 +3178,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, if (IS_ERR(kbuf)) return PTR_ERR(kbuf); - tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len), - sizeof(unsigned long), - GFP_KERNEL); + tmp_bitmap = bitmap_zalloc(bitmap_len, GFP_KERNEL); if (!tmp_bitmap) { kfree(kbuf); return -ENOMEM; @@ -3271,7 +3269,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, *ppos += *lenp; } - kfree(tmp_bitmap); + bitmap_free(tmp_bitmap); return err; }