RE: [PATCH v3] regmap: debugfs: Fix a memory leak when calling regmap_attach_dev

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx> 
Sent: Wednesday, December 30, 2020 5:49 PM
To: Wang, Xiaolei <Xiaolei.Wang@xxxxxxxxxxxxx>; kernel-janitors@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx; David Lechner <david@xxxxxxxxxxxxxx>; Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>; Mark Brown <broonie@xxxxxxxxxx>; Rafael J. Wysocki <rafael@xxxxxxxxxx>; Julia Lawall <julia.lawall@xxxxxxx>
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




[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux