diff mbox series

[-next] lightnvm: pblk: fix error handling of pblk_lines_init()

Message ID 1537941384-25324-1-git-send-email-weiyongjun1@huawei.com (mailing list archive)
State New, archived
Headers show
Series [-next] lightnvm: pblk: fix error handling of pblk_lines_init() | expand

Commit Message

Wei Yongjun Sept. 26, 2018, 5:56 a.m. UTC
In the too many bad blocks error handling case, we should release all
the alloced resources instead direct return, otherwise it will cause
memory leak.

Fixes: 2deeefc02dff ("lightnvm: pblk: fail gracefully on line alloc. failure")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/lightnvm/pblk-init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Hans Holmberg Sept. 26, 2018, 6:29 a.m. UTC | #1
On Wed, Sep 26, 2018 at 7:47 AM Wei Yongjun <weiyongjun1@huawei.com> wrote:
>
> In the too many bad blocks error handling case, we should release all
> the alloced resources instead direct return, otherwise it will cause
> memory leak.
>
> Fixes: 2deeefc02dff ("lightnvm: pblk: fail gracefully on line alloc. failure")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
> ---
>  drivers/lightnvm/pblk-init.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
> index 537e98f..a26f4e6 100644
> --- a/drivers/lightnvm/pblk-init.c
> +++ b/drivers/lightnvm/pblk-init.c
> @@ -1083,7 +1083,8 @@ static int pblk_lines_init(struct pblk *pblk)
>
>         if (!nr_free_chks) {
>                 pblk_err(pblk, "too many bad blocks prevent for sane instance\n");
> -               return -EINTR;
> +               ret = -EINTR;
> +               goto fail_free_lines;
>         }
>
>         pblk_set_provision(pblk, nr_free_chks);
>

Looks good to me.

Reviewed-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Matias Bjorling Sept. 29, 2018, 7:55 p.m. UTC | #2
On 9/26/18 8:29 AM, Hans Holmberg wrote:
> On Wed, Sep 26, 2018 at 7:47 AM Wei Yongjun <weiyongjun1@huawei.com> wrote:
>>
>> In the too many bad blocks error handling case, we should release all
>> the alloced resources instead direct return, otherwise it will cause
>> memory leak.
>>
>> Fixes: 2deeefc02dff ("lightnvm: pblk: fail gracefully on line alloc. failure")
>> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
>> ---
>>   drivers/lightnvm/pblk-init.c | 3 ++-
>>   1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
>> index 537e98f..a26f4e6 100644
>> --- a/drivers/lightnvm/pblk-init.c
>> +++ b/drivers/lightnvm/pblk-init.c
>> @@ -1083,7 +1083,8 @@ static int pblk_lines_init(struct pblk *pblk)
>>
>>          if (!nr_free_chks) {
>>                  pblk_err(pblk, "too many bad blocks prevent for sane instance\n");
>> -               return -EINTR;
>> +               ret = -EINTR;
>> +               goto fail_free_lines;
>>          }
>>
>>          pblk_set_provision(pblk, nr_free_chks);
>>
> 
> Looks good to me.
> 
> Reviewed-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
> 

Thanks. Applied for 4.20.
diff mbox series

Patch

diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c
index 537e98f..a26f4e6 100644
--- a/drivers/lightnvm/pblk-init.c
+++ b/drivers/lightnvm/pblk-init.c
@@ -1083,7 +1083,8 @@  static int pblk_lines_init(struct pblk *pblk)
 
 	if (!nr_free_chks) {
 		pblk_err(pblk, "too many bad blocks prevent for sane instance\n");
-		return -EINTR;
+		ret = -EINTR;
+		goto fail_free_lines;
 	}
 
 	pblk_set_provision(pblk, nr_free_chks);