]> git.baikalelectronics.ru Git - kernel.git/commit
hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined
authorEliav Farber <farbere@amazon.com>
Thu, 8 Sep 2022 15:24:30 +0000 (15:24 +0000)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 8 Sep 2022 18:54:04 +0000 (11:54 -0700)
commit621b7165a6299efe3fb645465ecf47fe0530e43b
treeb2b80453fe6490b5c07f7a5ce7298e8cf787acec
parent9f5eaf3aa68e63a5d73e1e6af3b3e79a17dc916a
hwmon: (mr75203) fix VM sensor allocation when "intel,vm-map" not defined

Bug - in case "intel,vm-map" is missing in device-tree ,'num' is set
to 0, and no voltage channel infos are allocated.

The reason num is set to 0 when "intel,vm-map" is missing is to set the
entire pvt->vm_idx[] with incremental channel numbers, but it didn't
take into consideration that same num is used later in devm_kcalloc().

If "intel,vm-map" does exist there is no need to set the unspecified
channels with incremental numbers, because the unspecified channels
can't be accessed in pvt_read_in() which is the only other place besides
the probe functions that uses pvt->vm_idx[].

This change fixes the bug by moving the incremental channel numbers
setting to be done only if "intel,vm-map" property is defined (starting
loop from 0), and removing 'num = 0'.

Fixes: e6dc6d6dd8bd ("hwmon: Add hardware monitoring driver for Moortec MR75203 PVT controller")
Signed-off-by: Eliav Farber <farbere@amazon.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20220908152449.35457-3-farbere@amazon.com
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/hwmon/mr75203.c