summaryrefslogtreecommitdiff
path: root/drivers/base
diff options
context:
space:
mode:
authorPankaj Dubey <pankaj.dubey@samsung.com>2014-09-27 08:17:55 +0400
committerMark Brown <broonie@kernel.org>2014-09-27 15:21:15 +0400
commit5336be8416a71b5568d2cf54a2f2066abe9f2a53 (patch)
tree6df5a5f1c43b18fd95882aedbb44a7565675c1a4 /drivers/base
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
downloadlinux-5336be8416a71b5568d2cf54a2f2066abe9f2a53.tar.xz
regmap: fix NULL pointer dereference in _regmap_write/read
If LOG_DEVICE is defined and map->dev is NULL it will lead to NULL pointer dereference. This patch fixes this issue by adding check for dev->NULL in all such places in regmap.c Signed-off-by: Pankaj Dubey <pankaj.dubey@samsung.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/regmap/regmap.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 78f43fb2fe84..b903aff59af3 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -1408,7 +1408,7 @@ int _regmap_write(struct regmap *map, unsigned int reg,
}
#ifdef LOG_DEVICE
- if (strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
+ if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
dev_info(map->dev, "%x <= %x\n", reg, val);
#endif
@@ -2058,7 +2058,7 @@ static int _regmap_read(struct regmap *map, unsigned int reg,
ret = map->reg_read(context, reg, val);
if (ret == 0) {
#ifdef LOG_DEVICE
- if (strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
+ if (map->dev && strcmp(dev_name(map->dev), LOG_DEVICE) == 0)
dev_info(map->dev, "%x => %x\n", reg, *val);
#endif