[PATCH linux dev-4.7] drivers/fsi: Free up allocated resources on fsi-master unbind
Christopher Bostic
cbostic at linux.vnet.ibm.com
Thu Mar 9 06:56:06 AEDT 2017
In order to allow repeated bind/unbind operations on fsi-master
the resources allocated during bind must be freed. Specifically
the scan file and dynamic memory. Also check for valid pointers
during unregister which is the path taken during unbind.
Signed-off-by: Christopher Bostic <cbostic at linux.vnet.ibm.com>
---
drivers/fsi/fsi-core.c | 8 ++++----
drivers/fsi/fsi-master-gpio.c | 2 ++
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/fsi/fsi-core.c b/drivers/fsi/fsi-core.c
index bbdf6b8..751c767 100644
--- a/drivers/fsi/fsi-core.c
+++ b/drivers/fsi/fsi-core.c
@@ -869,11 +869,11 @@ EXPORT_SYMBOL_GPL(fsi_master_register);
void fsi_master_unregister(struct fsi_master *master)
{
- if (master->idx >= 0) {
- ida_simple_remove(&master_ida, master->idx);
- master->idx = -1;
- }
+ if (!master || !master->dev || master->idx < 0)
+ return;
+ ida_simple_remove(&master_ida, master->idx);
+ master->idx = -1;
device_remove_file(master->dev, &dev_attr_fsi_ipoll_period);
fsi_master_unscan(master);
put_device(master->dev);
diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index 49f3399..3693b3d 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -566,6 +566,8 @@ static int fsi_master_gpio_remove(struct platform_device *pdev)
if (master->gpio_mux)
devm_gpiod_put(&pdev->dev, master->gpio_mux);
fsi_master_unregister(&master->master);
+ device_remove_file(&pdev->dev, &dev_attr_scan);
+ devm_kfree(&pdev->dev, master);
return 0;
}
--
1.8.2.2
More information about the openbmc
mailing list