lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 28 Sep 2016 15:51:19 -0400
From:   Jes Sorensen <Jes.Sorensen@...hat.com>
To:     SF Markus Elfring <elfring@...rs.sourceforge.net>
Cc:     linux-raid@...r.kernel.org, Shaohua Li <shli@...nel.org>,
        LKML <linux-kernel@...r.kernel.org>,
        kernel-janitors@...r.kernel.org,
        Julia Lawall <julia.lawall@...6.fr>
Subject: Re: [PATCH 01/16] md/bitmap: Use kmalloc_array() in bitmap_storage_alloc()

SF Markus Elfring <elfring@...rs.sourceforge.net> writes:
> From: Markus Elfring <elfring@...rs.sourceforge.net>
> Date: Tue, 27 Sep 2016 13:01:07 +0200
>
> * A multiplication for the size determination of a memory allocation
>   indicated that an array data structure should be processed.
>   Thus use the corresponding function "kmalloc_array".
>
>   This issue was detected by using the Coccinelle software.
>
> * Replace the specification of a data type by a pointer dereference
>   to make the corresponding size determination a bit safer according to
>   the Linux coding style convention.
>
> Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
> ---
>  drivers/md/bitmap.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
> index 13041ee..8cfb02c 100644
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -760,9 +760,9 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
>  
>  	num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
>  	offset = slot_number * num_pages;
> -
> -	store->filemap = kmalloc(sizeof(struct page *)
> -				 * num_pages, GFP_KERNEL);
> +	store->filemap = kmalloc_array(num_pages,
> +				       sizeof(*store->filemap),
> +				       GFP_KERNEL);

If you have to make cosmetic changes for the sake of it, then at least
use the 80 characters per line that you have available.

This one makes the code uglier.

Jes

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ