Commit f2c6a5fb authored by Andrei Epure's avatar Andrei Epure Committed by Anton Vorontsov

charger-manager: Use kmemdup instead of kzalloc + memcpy

Patch found using coccinelle.
Signed-off-by: default avatarAndrei Epure <epure.andrei@gmail.com>
Signed-off-by: default avatarAnton Vorontsov <anton@enomsg.org>
parent f6e0b081
......@@ -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" */
/*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment