]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
regmap: fix NULL pointer dereference in _regmap_write/read
authorPankaj Dubey <pankaj.dubey@samsung.com>
Sat, 27 Sep 2014 04:17:55 +0000 (09:47 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Oct 2014 16:38:20 +0000 (09:38 -0700)
commit 5336be8416a71b5568d2cf54a2f2066abe9f2a53 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/regmap/regmap.c

index 2ea056c09aebbe3ab9eb67411c578d1294cc0a8b..5277f9a80c2cb9d863b01a8ebf9d6800807976c4 100644 (file)
@@ -1308,7 +1308,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
 
@@ -1739,7 +1739,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