lkml.org 
[lkml]   [2021]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 5.10 086/103] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev
On Fri, Jan 15, 2021 at 09:18:19PM +0100, Pavel Machek wrote:
> Hi!
>
> > From: Xiaolei Wang <xiaolei.wang@windriver.com>
> >
> > commit cffa4b2122f5f3e53cf3d529bbc74651f95856d5 upstream.
> >
> > After initializing the regmap through
> > syscon_regmap_lookup_by_compatible, then regmap_attach_dev to the
> > device, because the debugfs_name has been allocated, there is no
> > need to redistribute it again
>
> ? redistribute?
>
> Anyway, this patch is clearly buggy:
>
> >
> > if (!strcmp(name, "dummy")) {
> > - kfree(map->debugfs_name);
> > + if (!map->debugfs_name)
> > + kfree(map->debugfs_name);
> >
>
> It runs kfree only if the variable is NULL. That's clearly useless,
> kfree(NULL) is NOP, and this causes memory leak.

Fixed by commit f6bcb4c7f366 ("regmap: debugfs: Fix a reversed if
statement in regmap_debugfs_init()") in mainline.

Cheers,
Nathan

\
 
 \ /
  Last update: 2021-01-15 21:24    [W:0.099 / U:1.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site