summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth/bcm203x.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-05-15 23:19:15 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-07-21 10:39:06 -0700
commit5ee283c063a236b19e4582c675a2d8d615d5809c (patch)
tree68a26906d9e25bbd5963c5feae54fbe29dc81fee /drivers/bluetooth/bcm203x.c
parentd1d10d783089cc26a14be92fc12fccda9aa6593a (diff)
downloadlinux-5ee283c063a236b19e4582c675a2d8d615d5809c.tar.gz
linux-5ee283c063a236b19e4582c675a2d8d615d5809c.tar.bz2
linux-5ee283c063a236b19e4582c675a2d8d615d5809c.zip
Bluetooth: Use kmemdup for drivers
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@diku.dk> Acked-by: Gustavo F. Padovan <padovan@profusion.mobi> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth/bcm203x.c')
-rw-r--r--drivers/bluetooth/bcm203x.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index b0c84c19f442..8b1b643a519b 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -224,7 +224,7 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
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_interface *intf, const struct usb_device_id
return -ENOMEM;
}
- memcpy(data->fw_data, firmware->data, firmware->size);
data->fw_size = firmware->size;
data->fw_sent = 0;