linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] regmap: dev_get_regmap_match(): fix string comparison
@ 2020-07-03 10:33 Marc Kleine-Budde
  2020-07-03 17:04 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Marc Kleine-Budde @ 2020-07-03 10:33 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rafael J. Wysocki, Mark Brown, Marc Kleine-Budde

This function is used by dev_get_regmap() to retrieve a regmap for the
specified device. If the device has more than one regmap, the name parameter
can be used to specify one.

The code here uses a pointer comparison to check for equal strings. This
however will probably always fail, as the regmap->name is allocated via
kstrdup_const() from the regmap's config->name.

Fix this by using strcmp() instead.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
Hey,

I stumbled over this by accident. AFAICS there's no-one on the kernel making
use of the "name" parameter.

regrads,
Marc

 drivers/base/regmap/regmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 06a796821e8b..795a62a04022 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1364,7 +1364,7 @@ static int dev_get_regmap_match(struct device *dev, void *res, void *data)
 
 	/* If the user didn't specify a name match any */
 	if (data)
-		return (*r)->name == data;
+		return !strcmp((*r)->name, data);
 	else
 		return 1;
 }
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] regmap: dev_get_regmap_match(): fix string comparison
  2020-07-03 10:33 [PATCH] regmap: dev_get_regmap_match(): fix string comparison Marc Kleine-Budde
@ 2020-07-03 17:04 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2020-07-03 17:04 UTC (permalink / raw)
  To: linux-kernel, Marc Kleine-Budde; +Cc: Rafael J. Wysocki

On Fri, 3 Jul 2020 12:33:15 +0200, Marc Kleine-Budde wrote:
> This function is used by dev_get_regmap() to retrieve a regmap for the
> specified device. If the device has more than one regmap, the name parameter
> can be used to specify one.
> 
> The code here uses a pointer comparison to check for equal strings. This
> however will probably always fail, as the regmap->name is allocated via
> kstrdup_const() from the regmap's config->name.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next

Thanks!

[1/1] regmap: dev_get_regmap_match(): fix string comparison
      commit: e84861fec32dee8a2e62bbaa52cded6b05a2a456

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-07-03 17:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 10:33 [PATCH] regmap: dev_get_regmap_match(): fix string comparison Marc Kleine-Budde
2020-07-03 17:04 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).