@@ -624,8 +624,11 @@ static int fsi_master_aspeed_probe(struct platform_device *pdev)
aspeed_master_init(aspeed);
rc = fsi_master_register(&aspeed->master);
- if (rc)
+ if (rc) {
+ put_device(&aspeed->master.dev);
+ aspeed = NULL;
goto err_release;
+ }
/* At this point, fsi_master_register performs the device_initialize(),
* and holds the sole reference on master.dev. This means the device
@@ -651,6 +654,7 @@ static int fsi_master_aspeed_remove(struct platform_device *pdev)
fsi_master_unregister(&aspeed->master);
clk_disable_unprepare(aspeed->clk);
+ put_device(&aspeed->master.dev);
return 0;
}
If fsi_master_register() fails, put_device() need be called to decrease refcount to 0, so that the name allocated in dev_set_name() can be freed in callback function kobject_cleanup(). Besides, the refcount is hold in fsi_master_aspeed_probe(), it need be put in fsi_master_aspeed_remove(). Fixes: 606397d67f41 ("fsi: Add ast2600 master driver") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> --- drivers/fsi/fsi-master-aspeed.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)