Browse Source

charger-manager: Use kmemdup instead of kzalloc + memcpy

Patch found using coccinelle.

Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
Andrei Epure 12 years ago
parent
commit
f2c6a5fb25
1 changed files with 1 additions and 2 deletions
  1. 1 2
      drivers/power/charger-manager.c

+ 1 - 2
drivers/power/charger-manager.c

@@ -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" */
 
 	/*