]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
charger-manager: Use kmemdup instead of kzalloc + memcpy
authorAndrei Epure <epure.andrei@gmail.com>
Wed, 27 Mar 2013 21:48:21 +0000 (23:48 +0200)
committerAnton Vorontsov <anton@enomsg.org>
Wed, 17 Apr 2013 01:56:38 +0000 (18:56 -0700)
Patch found using coccinelle.

Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
drivers/power/charger-manager.c

index 8acc3f8d303c70876e9e53e01a3dffa985cddc44..fefc39fe42bef0e600a47d5e2aade039e6a96d83 100644 (file)
@@ -1485,13 +1485,12 @@ static int charger_manager_probe(struct platform_device *pdev)
 
        /* Basic Values. Unspecified are Null or 0 */
        cm->dev = &pdev->dev;
-       cm->desc = kzalloc(sizeof(struct charger_desc), GFP_KERNEL);
+       cm->desc = kmemdup(desc, sizeof(struct charger_desc), GFP_KERNEL);
        if (!cm->desc) {
                dev_err(&pdev->dev, "Cannot allocate memory.\n");
                ret = -ENOMEM;
                goto err_alloc_desc;
        }
-       memcpy(cm->desc, desc, sizeof(struct charger_desc));
        cm->last_temp_mC = INT_MIN; /* denotes "unmeasured, yet" */
 
        /*