[PATCH linux dev-4.7] drivers/fsi: Free up allocated resources on fsi-master unbind

Joel Stanley joel at jms.id.au
Thu Mar 9 21:54:27 AEDT 2017


On Thu, Mar 9, 2017 at 9:20 PM, Joel Stanley <joel at jms.id.au> wrote:
> On Thu, Mar 9, 2017 at 6:26 AM, Christopher Bostic
> <cbostic at linux.vnet.ibm.com> wrote:
>> 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>
>
> This patch does not apply to dev-4.7. Can you please rebase it?
>
> a4a89c237856e2ee3b00db7cd5febf075b695760 is the tip of dev-4.7 at the moment.

That should read e97a91f178e55719b08d48af7f592b18cfd4da91.

>
>> ---
>>  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