From: Marc Kleine-Budde Date: Fri, 3 Jul 2020 10:33:15 +0000 (+0200) Subject: regmap: dev_get_regmap_match(): fix string comparison X-Git-Tag: v4.9.232~38 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=05f479dce24e94c57b1e28ffa12f149fd3b8f31d;p=platform%2Fkernel%2Flinux-amlogic.git regmap: dev_get_regmap_match(): fix string comparison [ Upstream commit e84861fec32dee8a2e62bbaa52cded6b05a2a456 ] 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 Link: https://lore.kernel.org/r/20200703103315.267996-1-mkl@pengutronix.de Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 1799a1dfa46e..cd984b59a8a1 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -1239,7 +1239,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; }