Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

regmap: debugfs: Fix a reversed if statement in regmap_debugfs_init()

This code will leak "map->debugfs_name" because the if statement is
reversed so it only frees NULL pointers instead of non-NULL. In
fact the if statement is not required and should just be removed
because kfree() accepts NULL pointers.

Fixes: cffa4b2122f5 ("regmap: debugfs: Fix a memory leak when calling regmap_attach_dev")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/X/RQpfAwRdLg0GqQ@mwanda
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Dan Carpenter and committed by
Mark Brown
f6bcb4c7 cffa4b21

+1 -3
+1 -3
drivers/base/regmap/regmap-debugfs.c
··· 594 594 } 595 595 596 596 if (!strcmp(name, "dummy")) { 597 - if (!map->debugfs_name) 598 - kfree(map->debugfs_name); 599 - 597 + kfree(map->debugfs_name); 600 598 map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", 601 599 dummy_index); 602 600 if (!map->debugfs_name)