* [PATCH 17/37] drivers/pci/hotplug: Use kmemdup
@ 2010-05-15 21:18 Julia Lawall
2010-05-18 22:05 ` Jesse Barnes
0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2010-05-15 21:18 UTC (permalink / raw)
To: Jesse Barnes, linux-pci, linux-kernel, kernel-janitors
From: Julia Lawall <julia@diku.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@diku.dk>
---
drivers/pci/hotplug/cpqphp_core.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff -u -p a/drivers/pci/hotplug/cpqphp_core.c b/drivers/pci/hotplug/cpqphp_core.c
--- 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 *
/* make our own copy of the pci bus structure,
* as we like tweaking it a lot */
- ctrl->pci_bus = kmalloc(sizeof(*ctrl->pci_bus), GFP_KERNEL);
+ ctrl->pci_bus = kmemdup(pdev->bus, sizeof(*ctrl->pci_bus), GFP_KERNEL);
if (!ctrl->pci_bus) {
err("out of memory\n");
rc = -ENOMEM;
goto err_free_ctrl;
}
- memcpy(ctrl->pci_bus, pdev->bus, sizeof(*ctrl->pci_bus));
ctrl->bus = pdev->bus->number;
ctrl->rev = pdev->revision;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 17/37] drivers/pci/hotplug: Use kmemdup
2010-05-15 21:18 [PATCH 17/37] drivers/pci/hotplug: Use kmemdup Julia Lawall
@ 2010-05-18 22:05 ` Jesse Barnes
0 siblings, 0 replies; 2+ messages in thread
From: Jesse Barnes @ 2010-05-18 22:05 UTC (permalink / raw)
To: Julia Lawall; +Cc: linux-pci, linux-kernel, kernel-janitors
On Sat, 15 May 2010 23:18:16 +0200 (CEST)
Julia Lawall <julia@diku.dk> wrote:
> From: Julia Lawall <julia@diku.dk>
>
> Use kmemdup when some other buffer is immediately copied into the
> allocated region.
Applied, thanks.
--
Jesse Barnes, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-05-18 22:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-15 21:18 [PATCH 17/37] drivers/pci/hotplug: Use kmemdup Julia Lawall
2010-05-18 22:05 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).