Skip to content

Commit

Permalink
charger-manager: Use kmemdup instead of kzalloc + memcpy
Browse files Browse the repository at this point in the history
Patch found using coccinelle.

Signed-off-by: Andrei Epure <epure.andrei@gmail.com>
Signed-off-by: Anton Vorontsov <anton@enomsg.org>
  • Loading branch information
Andrei Epure authored and Anton Vorontsov committed Apr 17, 2013
1 parent f6e0b08 commit f2c6a5f
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions drivers/power/charger-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -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" */

/*
Expand Down

0 comments on commit f2c6a5f

Please sign in to comment.