summaryrefslogtreecommitdiff
path: root/drivers/base/regmap
diff options
context:
space:
mode:
authorSergey SENOZHATSKY <sergey.senozhatsky.work@gmail.com>2015-08-31 12:54:58 +0300
committerMark Brown <broonie@kernel.org>2015-08-31 13:38:36 +0300
commit17649c90ff4c5246bb4babf6260029968a6d119d (patch)
tree1d6d28160ef5288d1eb073889309053c707195e4 /drivers/base/regmap
parent29332534e2b68b5889a40ccb6606ba0d06750a69 (diff)
downloadlinux-17649c90ff4c5246bb4babf6260029968a6d119d.tar.xz
regmap: fix a NULL pointer dereference in __regmap_init
__regmap_init() may receive a NULL `struct regmap_bus *bus' pointer, for example, from snd_hdac_regmap_init(), and it make sure that it does not NULL deference `bus`, except around ->max_raw_read and ->max_raw_write initialisation. Add missing check. Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/base/regmap')
-rw-r--r--drivers/base/regmap/regmap.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index d2efa4b33294..2ffdb62f75f7 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -579,8 +579,10 @@ struct regmap *regmap_init(struct device *dev,
map->use_single_read = config->use_single_rw || !bus || !bus->read;
map->use_single_write = config->use_single_rw || !bus || !bus->write;
map->can_multi_write = config->can_multi_write && bus && bus->write;
- map->max_raw_read = bus->max_raw_read;
- map->max_raw_write = bus->max_raw_write;
+ if (bus) {
+ map->max_raw_read = bus->max_raw_read;
+ map->max_raw_write = bus->max_raw_write;
+ }
map->dev = dev;
map->bus = bus;
map->bus_context = bus_context;