diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-15 23:21:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-17 16:31:15 -0700 |
commit | 94002c07ff0e207a883519ccc35c0b5390b29331 (patch) | |
tree | b730a75ef2ad76d1e3a322e5982b30ca46b6c487 /drivers/staging/hv/vmbus.c | |
parent | 96fe9ee2c2dfe3268961f3873ea6098b9b9f27c2 (diff) | |
download | linux-stable-94002c07ff0e207a883519ccc35c0b5390b29331.tar.gz linux-stable-94002c07ff0e207a883519ccc35c0b5390b29331.tar.bz2 linux-stable-94002c07ff0e207a883519ccc35c0b5390b29331.zip |
Staging: 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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv/vmbus.c')
-rw-r--r-- | drivers/staging/hv/vmbus.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/staging/hv/vmbus.c b/drivers/staging/hv/vmbus.c index 0a9d8459db0c..007543bdb410 100644 --- a/drivers/staging/hv/vmbus.c +++ b/drivers/staging/hv/vmbus.c @@ -185,11 +185,10 @@ static void VmbusOnMsgDPC(struct hv_driver *drv) /* no msg */ break; } else { - copied = kmalloc(sizeof(*copied), GFP_ATOMIC); + copied = kmemdup(msg, sizeof(*copied), GFP_ATOMIC); if (copied == NULL) continue; - memcpy(copied, msg, sizeof(*copied)); osd_schedule_callback(gVmbusConnection.WorkQueue, VmbusOnChannelMessage, (void *)copied); |