lkml.org 
[lkml]   [2020]   [Dec]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectRE: [PATCH v3] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev
Date
Hi Markus

Thank you very much, very good suggestion, do I need to re-send a patch to fix this problem, or modify the previous patch and send it again?

Thanks
Xiaolei


> +++ b/drivers/base/regmap/regmap-debugfs.c
> @@ -582,18 +582,25 @@ void regmap_debugfs_init(struct regmap *map)

> + map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
> devname, name);

> I suggest to reconsider the alignment for function call parameters for this patch.



> + if (!map->debugfs_name)
> + kfree(map->debugfs_name);

> Such a null pointer check is redundant.

> See also:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/free/ifnullfree.cocci?id=139711f033f636cc78b6aaf7363252241b9698ef#n2




-----Original Message-----
From: Markus Elfring <Markus.Elfring@web.de>
Sent: Wednesday, December 30, 2020 5:49 PM
To: Wang, Xiaolei <Xiaolei.Wang@windriver.com>; kernel-janitors@vger.kernel.org
Cc: linux-kernel@vger.kernel.org; David Lechner <david@lechnology.com>; Greg Kroah-Hartman <gregkh@linuxfoundation.org>; Mark Brown <broonie@kernel.org>; Rafael J. Wysocki <rafael@kernel.org>; Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH v3] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev


> +++ b/drivers/base/regmap/regmap-debugfs.c
> @@ -582,18 +582,25 @@ void regmap_debugfs_init(struct regmap *map)

> + map->debugfs_name = kasprintf(GFP_KERNEL, "%s-%s",
> devname, name);

I suggest to reconsider the alignment for function call parameters for this patch.



> + if (!map->debugfs_name)
> + kfree(map->debugfs_name);

Such a null pointer check is redundant.

See also:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/free/ifnullfree.cocci?id=139711f033f636cc78b6aaf7363252241b9698ef#n2

Regards,
Markus
\
 
 \ /
  Last update: 2020-12-30 11:16    [W:0.051 / U:0.992 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site