Skip to content

Commit

Permalink
regmap: dev_get_regmap_match(): fix string comparison
Browse files Browse the repository at this point in the history
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>
Link: https://lore.kernel.org/r/20200703103315.267996-1-mkl@pengutronix.de
Signed-off-by: Mark Brown <broonie@kernel.org>
  • Loading branch information
Marc Kleine-Budde authored and Mark Brown committed Jul 3, 2020
1 parent 95b2c3e commit e84861f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit e84861f

Please sign in to comment.