Re: [PATCH 04/11] hwmon: (ina2xx) Mark regmap_config as const

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 8/29/24 07:54, Tzung-Bi Shih wrote:
On Tue, Aug 27, 2024 at 08:34:48AM -0700, Guenter Roeck wrote:
Doing so reveals a potential problem in the driver: If both supported
chips are present in a single system, the maximum number of registers
may race when devic es are instantiated since max_registers is updated
                      ^

Fixed, thanks.


in the probe function. Solve the problem by setting .max_registers to the
maximum register address of all supported chips. This does not make a
practical difference while fixing the potential race condition and reducing
code complexity.

It also makes regmap could access out-of-boundary (e.g. [1]).  Is it harmless?

[1]: https://elixir.bootlin.com/linux/v6.10/source/drivers/base/regmap/regmap-debugfs.c#L441


Yes, that is not worth bothering about. Any driver not using regmap but accessing
i2c registers directly could do the same, after all. The regmap limits are just
another level of protection against invalid accesses, but they are not essential.
On top of that, direct i2c accesses to the chip are still possible, even
while using regmap.

If we wanted to be really paranoid, we could provide chip specific readable_reg /
writeable_reg / volatile_reg callbacks, but IMO that would be overkill.

Thanks,
Guenter





[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux