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:	Sun, 16 May 2010 01:53:31 -0300
From:	"Gustavo F. Padovan" <gustavo@...ovan.org>
To:	Julia Lawall <julia@...u.dk>
Cc:	Marcel Holtmann <marcel@...tmann.org>,
	linux-bluetooth@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 20/37] drivers/bluetooth: Use kmemdup

* Julia Lawall <julia@...u.dk> [2010-05-15 23:19:15 +0200]:

> From: Julia Lawall <julia@...u.dk>
> 
> Use kmemdup when some other buffer is immediately copied into the
> allocated region.
> 
> A simplified version of the semantic patch that makes this change is as
> follows: (http://coccinelle.lip6.fr/)
> 
> // <smpl>
> @@
> expression from,to,size,flag;
> statement S;
> @@
> 
> -  to = \(kmalloc\|kzalloc\)(size,flag);
> +  to = kmemdup(from,size,flag);
>    if (to==NULL || ...) S
> -  memcpy(to, from, size);
> // </smpl>
> 
> Signed-off-by: Julia Lawall <julia@...u.dk>
> 
> ---
>  drivers/bluetooth/bcm203x.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff -u -p a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
> --- a/drivers/bluetooth/bcm203x.c
> +++ b/drivers/bluetooth/bcm203x.c
> @@ -224,7 +224,7 @@ static int bcm203x_probe(struct usb_inte
>  
>  	BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
>  
> -	data->fw_data = kmalloc(firmware->size, GFP_KERNEL);
> +	data->fw_data = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
>  	if (!data->fw_data) {
>  		BT_ERR("Can't allocate memory for firmware image");
>  		release_firmware(firmware);
> @@ -234,7 +234,6 @@ static int bcm203x_probe(struct usb_inte
>  		return -ENOMEM;
>  	}
>  
> -	memcpy(data->fw_data, firmware->data, firmware->size);
>  	data->fw_size = firmware->size;
>  	data->fw_sent = 0;


Acked-by: Gustavo F. Padovan <padovan@...fusion.mobi>

-- 
Gustavo F. Padovan
http://padovan.org
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists