lkml.org 
[lkml]   [2021]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] powerpc: mpc52xx_gpt: fix a potential memory leak
Michael Ellerman <mpe@ellerman.id.au> wrote:
> > When some internal memory errors happend in of_iomap(), we should free
> > gpt to prevent memory leak.
>
> But it's allocated with devm_kzalloc(), so the devres core is meant to
> free it for us isn't it?

Yes, maybe you are right. I did that as I mentioned when gpt-regs is NULL, it 
will return -ENOMEM, which is the same when gpt is NULL. So I suppose to
free it in time is better:
> gpt = devm_kzalloc(&ofdev->dev, sizeof *gpt, GFP_KERNEL);
> if (!gpt)
> return -ENOMEM;

cheers

\
 
 \ /
  Last update: 2021-12-13 03:27    [W:0.048 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site