Re: [PATCH 1/2] regmap: fix NULL pointer dereference in regmap_name_read_file()

From: David Lechner
Date: Wed Jan 24 2018 - 11:04:51 EST


On 01/24/2018 05:30 AM, Mark Brown wrote:
On Tue, Jan 23, 2018 at 04:53:42PM -0600, David Lechner wrote:

This fixes a possible NULL pointer dereference oops in
regmap_name_read_file() when the regmap does not have a device
associated with it.

How are you managing to get a regmap without a device associated with
it?


I'm using syscon_regmap_lookup_by_compatible(), which calls:

regmap_init_mmio(NULL, base, &syscon_config)

NULL being the struct device *dev parameter.

There are several clock drivers that do that as well. I'm writing
another clock driver and will need to do the same thing for some non-DT
boards. I tried using a device, but clocks are initialized fairly early
in the boot process and kobject is not initialized yet, so you can't
register a platform device at that point.