Re: [PATCH v2 2/7] nvmem: fix another memory leak in error path

From: Bartosz Golaszewski
Date: Tue Feb 18 2020 - 04:50:48 EST


wt., 18 lut 2020 o 10:47 Srinivas Kandagatla
<srinivas.kandagatla@xxxxxxxxxx> napisaÅ(a):
>
>
>
> On 18/02/2020 09:42, Bartosz Golaszewski wrote:
> > From: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
> >
> > The nvmem struct is only freed on the first error check after its
> > allocation and leaked after that. Fix it with a new label.
> >
> > Cc: <stable@xxxxxxxxxxxxxxx>
> > Signed-off-by: Bartosz Golaszewski <bgolaszewski@xxxxxxxxxxxx>
>
> looks like 1/7 introduced the bug and 2/7 fixes it.
> IMO, you should 1/7 and 2/7 should be single patch.
>

The bug already exists in mainline - the nvmem object is only freed if
ida_simple_get() fails, but any subsequent error leads to a memory
leak. In other words: it doesn't matter if it's a single patch or two.

Bart