Skip to content

Commit 52f527d

Browse files
Haoxiang LiChristophe Leroy (CS GROUP)
authored andcommitted
bus: fsl-mc: fix an error handling in fsl_mc_device_add()
In fsl_mc_device_add(), device_initialize() is called first. put_device() should be called to drop the reference if error occurs. And other resources would be released via put_device -> fsl_mc_device_release. So remove redundant kfree() in error handling path. Fixes: bbf9d17 ("staging: fsl-mc: Freescale Management Complex (fsl-mc) bus driver") Cc: [email protected] Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Signed-off-by: Su Hui <[email protected]> Suggested-by: Christophe Leroy (CS GROUP) <[email protected]> Signed-off-by: Haoxiang Li <[email protected]> Reviewed-by: Ioana Ciornei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christophe Leroy (CS GROUP) <[email protected]>
1 parent 65d5727 commit 52f527d

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

drivers/bus/fsl-mc/fsl-mc-bus.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -896,11 +896,7 @@ int fsl_mc_device_add(struct fsl_mc_obj_desc *obj_desc,
896896
return 0;
897897

898898
error_cleanup_dev:
899-
kfree(mc_dev->regions);
900-
if (mc_bus)
901-
kfree(mc_bus);
902-
else
903-
kfree(mc_dev);
899+
put_device(&mc_dev->dev);
904900

905901
return error;
906902
}

0 commit comments

Comments
 (0)