[media] drx-j: Use kmemdup instead of kmalloc + memcpy
authorBenoit Taine <benoit.taine@lip6.fr>
Mon, 26 May 2014 15:21:26 +0000 (12:21 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 4 Jul 2014 18:34:21 +0000 (15:34 -0300)
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci

Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/dvb-frontends/drx39xyj/drxj.c

index 9482954fd453bbda66805a40a6b1aceab6adbfb9..3795f65564f87c4156b89c6eef50626a4479294b 100644 (file)
@@ -12272,22 +12272,20 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
        if (demod == NULL)
                goto error;
 
-       demod_addr = kmalloc(sizeof(struct i2c_device_addr), GFP_KERNEL);
+       demod_addr = kmemdup(&drxj_default_addr_g,
+                            sizeof(struct i2c_device_addr), GFP_KERNEL);
        if (demod_addr == NULL)
                goto error;
-       memcpy(demod_addr, &drxj_default_addr_g,
-              sizeof(struct i2c_device_addr));
 
-       demod_comm_attr = kmalloc(sizeof(struct drx_common_attr), GFP_KERNEL);
+       demod_comm_attr = kmemdup(&drxj_default_comm_attr_g,
+                                 sizeof(struct drx_common_attr), GFP_KERNEL);
        if (demod_comm_attr == NULL)
                goto error;
-       memcpy(demod_comm_attr, &drxj_default_comm_attr_g,
-              sizeof(struct drx_common_attr));
 
-       demod_ext_attr = kmalloc(sizeof(struct drxj_data), GFP_KERNEL);
+       demod_ext_attr = kmemdup(&drxj_data_g, sizeof(struct drxj_data),
+                                GFP_KERNEL);
        if (demod_ext_attr == NULL)
                goto error;
-       memcpy(demod_ext_attr, &drxj_data_g, sizeof(struct drxj_data));
 
        /* setup the state */
        state->i2c = i2c;