OSDN Git Service

media: dvb-frontends: Use kmemdup instead of duplicating its function
authorzhong jiang <zhongjiang@huawei.com>
Wed, 19 Sep 2018 08:16:09 +0000 (04:16 -0400)
committerMauro Carvalho Chehab <mchehab+samsung@kernel.org>
Mon, 3 Dec 2018 18:27:55 +0000 (13:27 -0500)
kmemdup has implemented the function that kmalloc() + memcpy().
We prefer to kmemdup rather than code opened implementation.

Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
drivers/media/dvb-frontends/lgdt3306a.c

index 0e1f5da..cee9c83 100644 (file)
@@ -2205,15 +2205,13 @@ static int lgdt3306a_probe(struct i2c_client *client,
        struct dvb_frontend *fe;
        int ret;
 
-       config = kzalloc(sizeof(struct lgdt3306a_config), GFP_KERNEL);
+       config = kmemdup(client->dev.platform_data,
+                        sizeof(struct lgdt3306a_config), GFP_KERNEL);
        if (config == NULL) {
                ret = -ENOMEM;
                goto fail;
        }
 
-       memcpy(config, client->dev.platform_data,
-                       sizeof(struct lgdt3306a_config));
-
        config->i2c_addr = client->addr;
        fe = lgdt3306a_attach(config, client->adapter);
        if (fe == NULL) {