aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/hotplug
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-05-15 17:18:16 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2010-05-18 18:02:09 -0400
commit8f6bce3c4f48bd79b57d6ac9f337f5aabee43ea7 (patch)
tree1085956145a6962060c18eb330ff7242e71208ba /drivers/pci/hotplug
parentb79995700e25dd6b0b0aff7edd0c102d1b6281f7 (diff)
PCI hotplug: Use kmemdup
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> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/hotplug')
-rw-r--r--drivers/pci/hotplug/cpqphp_core.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
index f184d1d2ecbe..cb7818ffd5cf 100644
--- a/drivers/pci/hotplug/cpqphp_core.c
+++ b/drivers/pci/hotplug/cpqphp_core.c
@@ -1075,13 +1075,12 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1075 1075
1076 /* make our own copy of the pci bus structure, 1076 /* make our own copy of the pci bus structure,
1077 * as we like tweaking it a lot */ 1077 * as we like tweaking it a lot */
1078 ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL); 1078 ctrl->pci_bus = kmemdup(pdev->bus, sizeof(*ctrl->pci_bus), GFP_KERNEL);
1079 if (!ctrl->pci_bus) { 1079 if (!ctrl->pci_bus) {
1080 err("out of memory\n"); 1080 err("out of memory\n");
1081 rc = -ENOMEM; 1081 rc = -ENOMEM;
1082 goto err_free_ctrl; 1082 goto err_free_ctrl;
1083 } 1083 }
1084 memcpy(ctrl->pci_bus, pdev->bus, sizeof(*ctrl->pci_bus));
1085 1084
1086 ctrl->bus = pdev->bus->number; 1085 ctrl->bus = pdev->bus->number;
1087 ctrl->rev = pdev->revision; 1086 ctrl->rev = pdev->revision;