Re: [PATCH] nvdimm: btt_devs: fix a NULL pointer dereference and a memory leak

From: Verma, Vishal L
Date: Fri Mar 22 2019 - 19:31:47 EST



On Fri, 2019-03-22 at 22:56 +0000, Verma, Vishal L wrote:
> On Fri, 2019-03-22 at 22:49 +0000, Verma, Vishal L wrote:
> > On Tue, 2019-03-12 at 03:15 -0500, Kangjie Lu wrote:
> > > In case kmemdup fails, the fix releases resources and returns to
> > > avoid the NULL pointer dereference.
> > > Also, the error paths in the following code should release
> > > resources to avoid memory leaks.
> > >
> > > Signed-off-by: Kangjie Lu <kjlu@xxxxxxx>
> > > ---
> > > drivers/nvdimm/btt_devs.c | 8 +++++++-
> > > 1 file changed, 7 insertions(+), 1 deletion(-)
> > >
> >
> > Looks good,
> > Reviewed-by: Vishal Verma <vishal.l.verma@xxxxxxxxx>
>
> Looking again, there is another kmemdup() call in __nd_btt_probe which
> is lacking error checking.
> And referring to your other related patch to namespace_devs, that has
> /several/ instances of the same thing.
>
> Instead of fixing just a couple of these, it might be worthwhile to send
> a wider cleanup patch to catch all of these, at least within
> drivers/nvdimm/ for starters, instead of a select few.

Hm, ignore this comment - these are the only two unchecked instances.