kernel/sysctl.c: Switch to bitmap_zalloc()
Subsystems (2)
PATCH 1/1 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 *.
Signed-off-by Andy Shevchenko <[email protected]>
--- kernel/sysctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
kernel/sysctl.c +2 -4
@@ -3167,9 +3167,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 ;
@@ -3260,7 +3258,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, *ppos += *lenp; } -kfree (tmp_bitmap); +bitmap_free (tmp_bitmap);return err; }
Signature · 1 line
2.20.1
Quoted 5 lines · Andy Shevchenko
Switch to
bitmap_zalloc()to show clearly what we are allocating. Besides that it returns pointer of bitmap type instead of opaque void *.Signed-off-by Andy Shevchenko <[email protected]>
Acked-by Kees Cook <[email protected]>
-Kees
Quoted 31 lines
--- kernel/sysctl.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)kernel/sysctl.c +2
-5@@ -3167,9 +3167,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 ;@@ -3260,7 +3258,7 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, *ppos += *lenp; } -kfree (tmp_bitmap); +bitmap_free (tmp_bitmap);return err; } --2.20.1
Signature · 1 line
Kees Cook