All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] lightnvm: fix memory leak in pblk_luns_init
@ 2018-02-22 21:01 Huaicheng Li
       [not found] ` <CANr0WEcDSy3YuZ8kaNuB7Z0wFfiV6AwT=bg4W3MNq--2txX2xQ@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Huaicheng Li @ 2018-02-22 21:01 UTC (permalink / raw)
  To: mb, jg; +Cc: linux-block, linux-kernel

Signed-off-by: Huaicheng Li <huaicheng@cs.uchicago.edu>
---
 drivers/lightnvm/pblk-init.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 93d671ca518e..330665d91d8d 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -510,6 +510,7 @@ static int pblk_luns_init(struct pblk *pblk, struct ppa_addr *luns)
 		if (ret) {
 			while (--i >= 0)
 				kfree(pblk->luns[i].bb_list);
+			kfree(pblk->luns);
 			return ret;
 		}
 	}
-- 
2.13.6

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] lightnvm: fix memory leak in pblk_luns_init
       [not found] ` <CANr0WEcDSy3YuZ8kaNuB7Z0wFfiV6AwT=bg4W3MNq--2txX2xQ@mail.gmail.com>
@ 2018-02-23  6:12   ` Matias Bjørling
  2018-02-23  8:56     ` Javier González
  0 siblings, 1 reply; 3+ messages in thread
From: Matias Bjørling @ 2018-02-23  6:12 UTC (permalink / raw)
  To: Huaicheng Li, Javier González; +Cc: linux-block, linux-kernel

On 02/23/2018 12:03 AM, Huaicheng Li wrote:
> Please ignore my previous email as I found the memory is free'ed at
> pblk_init()'s error handling logic.
> Sorry for the interruption.
> 
> On Thu, Feb 22, 2018 at 3:01 PM, Huaicheng Li <huaicheng@cs.uchicago.edu>
> wrote:
> 
>> Signed-off-by: Huaicheng Li <huaicheng@cs.uchicago.edu>
>> ---
>> drivers/lightnvm/pblk-init.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
>> index 93d671ca518e..330665d91d8d 100644
>> --- a/drivers/lightnvm/pblk-init.c
>> +++ b/drivers/lightnvm/pblk-init.c
>> @@ -510,6 +510,7 @@ static int pblk_luns_init(struct pblk *pblk, struct
>> ppa_addr *luns)
>>                  if (ret) {
>>                          while (--i >= 0)
>>                                  kfree(pblk->luns[i].bb_list);
>> +                       kfree(pblk->luns);
>>                          return ret;
>>                  }
>>          }
>> --
>> 2.13.6
>>
>>
> 

No worries. The initialization part is pretty complex due to all the 
data structures being set up. I would love to have a clean 
initialization function, which cleans up after it self. But being able 
to share the "fail" bringup and tear-down code is very helpful and makes 
other parts easier.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] lightnvm: fix memory leak in pblk_luns_init
  2018-02-23  6:12   ` Matias Bjørling
@ 2018-02-23  8:56     ` Javier González
  0 siblings, 0 replies; 3+ messages in thread
From: Javier González @ 2018-02-23  8:56 UTC (permalink / raw)
  To: Matias Bjørling; +Cc: Huaicheng Li, linux-block, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1763 bytes --]

> On 23 Feb 2018, at 07.12, Matias Bjørling <mb@lightnvm.io> wrote:
> 
> On 02/23/2018 12:03 AM, Huaicheng Li wrote:
>> Please ignore my previous email as I found the memory is free'ed at
>> pblk_init()'s error handling logic.
>> Sorry for the interruption.
>> On Thu, Feb 22, 2018 at 3:01 PM, Huaicheng Li <huaicheng@cs.uchicago.edu>
>> wrote:
>>> Signed-off-by: Huaicheng Li <huaicheng@cs.uchicago.edu>
>>> ---
>>> drivers/lightnvm/pblk-init.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>> 
>>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
>>> index 93d671ca518e..330665d91d8d 100644
>>> --- a/drivers/lightnvm/pblk-init.c
>>> +++ b/drivers/lightnvm/pblk-init.c
>>> @@ -510,6 +510,7 @@ static int pblk_luns_init(struct pblk *pblk, struct
>>> ppa_addr *luns)
>>>                 if (ret) {
>>>                         while (--i >= 0)
>>>                                 kfree(pblk->luns[i].bb_list);
>>> +                       kfree(pblk->luns);
>>>                         return ret;
>>>                 }
>>>         }
>>> --
>>> 2.13.6
> 
> No worries. The initialization part is pretty complex due to all the
> data structures being set up. I would love to have a clean
> initialization function, which cleans up after it self. But being able
> to share the "fail" bringup and tear-down code is very helpful and
> makes other parts easier.

As part of the 2.0 patches, I took a first try at refactoring the
init/exit sequences to maintain the same fail paths but minimizing
dependencies across structures. One of the big parts have been the bad
block initialization, which now is much cleaner, but still needs more
work to be as I would like it to. Patches are very welcome :)

Javier

[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-02-23  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-22 21:01 [PATCH] lightnvm: fix memory leak in pblk_luns_init Huaicheng Li
     [not found] ` <CANr0WEcDSy3YuZ8kaNuB7Z0wFfiV6AwT=bg4W3MNq--2txX2xQ@mail.gmail.com>
2018-02-23  6:12   ` Matias Bjørling
2018-02-23  8:56     ` Javier González

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.