Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1285121

Re: gigaset: freeing an active object

From Tilman Schmidt <tilman@imap.cc>
Newsgroups linux.kernel
Subject Re: gigaset: freeing an active object
Date 2015-12-07 10:30 +0100
Message-ID <qD0hj-2Dk-1@gated-at.bofh.it> (permalink)
References (6 earlier) <qAB3I-739-13@gated-at.bofh.it> <qBpjQ-5xC-15@gated-at.bofh.it> <qCHHH-7vV-13@gated-at.bofh.it> <qCJzQ-fR-19@gated-at.bofh.it> <qCNWO-3cn-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

Am 06.12.2015 um 21:12 schrieb Paul Bolle:
> On zo, 2015-12-06 at 16:29 +0100, Tilman Schmidt wrote:
>> So the solution might be as simple as moving the kfree() call from
>> gigaset_freecshw() to gigaset_device_release(). Something like this:
>>
>> --- a/drivers/isdn/gigaset/ser-gigaset.c
>> +++ b/drivers/isdn/gigaset/ser-gigaset.c
>> @@ -370,19 +370,18 @@ static void gigaset_freecshw(struct cardstate
>> *cs)
>>         tasklet_kill(&cs->write_tasklet);
>>         if (!cs->hw.ser)
>>                 return;
>> -       dev_set_drvdata(&cs->hw.ser->dev.dev, NULL);
>>         platform_device_unregister(&cs->hw.ser->dev);
>> -       kfree(cs->hw.ser);
>> -       cs->hw.ser = NULL;
>>  }
>>
>>  static void gigaset_device_release(struct device *dev)
>>  {
>> -       struct platform_device *pdev = to_platform_device(dev);
>> +       struct cardstate *cs = dev_get_drvdata(dev);
>>
>> -       /* adapted from platform_device_release() in drivers/base/platform.c */
>> -       kfree(dev->platform_data);
>> -       kfree(pdev->resource);
>> +       if (!cs)
>> +               return;
>> +       dev_set_drvdata(dev, NULL);
>> +       kfree(cs->hw.ser);
>> +       cs->hw.ser = NULL;
>>  }
> 
> This solution assumes that the struct platform_device is moved out of
> the struct ser_cardstate, doesn't it? In other words, this is something
> to do on top of my (draft) patch.

No, that wasn't my intention. I thought of that solution as an
alternative, not an increment to your patch.

> Otherwise we'd still be freeing memory
> managed through reference counting.

Now I#m confused. I thought by following Peter's suggestion to put the
kfree() in the release method we'd avoid just that.

Regards,
Tilman

-- 
Tilman Schmidt                              E-Mail: tilman@imap.cc
Bonn, Germany
Nous, on a des fleurs et des bougies pour nous protéger.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-11-30 19:10 +0100
  Re: gigaset: freeing an active object Tilman Schmidt <tilman@imap.cc> - 2015-11-30 19:40 +0100
    Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-11-30 22:10 +0100
      Re: gigaset: freeing an active object Tilman Schmidt <tilman@imap.cc> - 2015-12-01 10:40 +0100
        Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-12-01 11:10 +0100
  Re: gigaset: freeing an active object Peter Hurley <peter@hurleysoftware.com> - 2015-12-03 00:50 +0100
    Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-12-06 14:40 +0100
      Re: gigaset: freeing an active object Tilman Schmidt <tilman@imap.cc> - 2015-12-06 16:40 +0100
        Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-12-06 21:20 +0100
          Re: gigaset: freeing an active object Tilman Schmidt <tilman@imap.cc> - 2015-12-07 10:30 +0100
            Re: gigaset: freeing an active object Paul Bolle <pebolle@tiscali.nl> - 2015-12-07 13:30 +0100
              Re: gigaset: freeing an active object Tilman Schmidt <tilman@imap.cc> - 2015-12-07 19:50 +0100

csiph-web