diff options
author | Julia Lawall <julia@diku.dk> | 2010-07-01 00:52:33 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-08-02 14:04:04 -0400 |
commit | 7a12f4b50dad4fdffd218c6fba6b9564bf86185e (patch) | |
tree | ebb73277de59c7ee5299d830c7bf976960cccecc /drivers/media/video/zoran | |
parent | cd3172d7dabdac4545d8246da62b570b9acf8058 (diff) |
V4L/DVB: drivers/media/video/zoran: 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: Douglas Schilling Landgraf <dougsland@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/zoran')
-rw-r--r-- | drivers/media/video/zoran/videocodec.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/media/video/zoran/videocodec.c b/drivers/media/video/zoran/videocodec.c index cf24956f3204..c01071635290 100644 --- a/drivers/media/video/zoran/videocodec.c +++ b/drivers/media/video/zoran/videocodec.c | |||
@@ -107,15 +107,14 @@ videocodec_attach (struct videocodec_master *master) | |||
107 | if (!try_module_get(h->codec->owner)) | 107 | if (!try_module_get(h->codec->owner)) |
108 | return NULL; | 108 | return NULL; |
109 | 109 | ||
110 | codec = | 110 | codec = kmemdup(h->codec, sizeof(struct videocodec), |
111 | kmalloc(sizeof(struct videocodec), GFP_KERNEL); | 111 | GFP_KERNEL); |
112 | if (!codec) { | 112 | if (!codec) { |
113 | dprintk(1, | 113 | dprintk(1, |
114 | KERN_ERR | 114 | KERN_ERR |
115 | "videocodec_attach: no mem\n"); | 115 | "videocodec_attach: no mem\n"); |
116 | goto out_module_put; | 116 | goto out_module_put; |
117 | } | 117 | } |
118 | memcpy(codec, h->codec, sizeof(struct videocodec)); | ||
119 | 118 | ||
120 | snprintf(codec->name, sizeof(codec->name), | 119 | snprintf(codec->name, sizeof(codec->name), |
121 | "%s[%d]", codec->name, h->attached); | 120 | "%s[%d]", codec->name, h->attached); |