1. 24 11月, 2019 2 次提交
  2. 05 10月, 2019 1 次提交
  3. 16 8月, 2019 2 次提交
  4. 25 6月, 2019 2 次提交
    • R
      hwmon: (pmbus/core) Treat parameters as paged if on multiple pages · d72a4c78
      Robert Hancock 提交于
      [ Upstream commit 4a60570dce658e3f8885bbcf852430b99f65aca5 ]
      
      Some chips have attributes which exist on more than one page but the
      attribute is not presently marked as paged. This causes the attributes
      to be generated with the same label, which makes it impossible for
      userspace to tell them apart.
      
      Marking all such attributes as paged would result in the page suffix
      being added regardless of whether they were present on more than one
      page or not, which might break existing setups. Therefore, we add a
      second check which treats the attribute as paged, even if not marked as
      such, if it is present on multiple pages.
      
      Fixes: b4ce237b ("hwmon: (pmbus) Introduce infrastructure to detect sensors and limit registers")
      Signed-off-by: NRobert Hancock <hancock@sedsystems.ca>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      d72a4c78
    • E
      hwmon: (core) add thermal sensors only if dev->of_node is present · 6029e581
      Eduardo Valentin 提交于
      [ Upstream commit c41dd48e21fae3e55b3670ccf2eb562fc1f6a67d ]
      
      Drivers may register to hwmon and request for also registering
      with the thermal subsystem (HWMON_C_REGISTER_TZ). However,
      some of these driver, e.g. marvell phy, may be probed from
      Device Tree or being dynamically allocated, and in the later
      case, it will not have a dev->of_node entry.
      
      Registering with hwmon without the dev->of_node may result in
      different outcomes depending on the device tree, which may
      be a bit misleading. If the device tree blob has no 'thermal-zones'
      node, the *hwmon_device_register*() family functions are going
      to gracefully succeed, because of-thermal,
      *thermal_zone_of_sensor_register() return -ENODEV in this case,
      and the hwmon error path handles this error code as success to
      cover for the case where CONFIG_THERMAL_OF is not set.
      However, if the device tree blob has the 'thermal-zones'
      entry, the *hwmon_device_register*() will always fail on callers
      with no dev->of_node, propagating -EINVAL.
      
      If dev->of_node is not present, calling of-thermal does not
      make sense. For this reason, this patch checks first if the
      device has a of_node before going over the process of registering
      with the thermal subsystem of-thermal interface. And in this case,
      when a caller of *hwmon_device_register*() with HWMON_C_REGISTER_TZ
      and no dev->of_node will still register with hwmon, but not with
      the thermal subsystem. If all the hwmon part bits are in place,
      the registration will succeed.
      
      Fixes: d560168b ("hwmon: (core) New hwmon registration API")
      Cc: Jean Delvare <jdelvare@suse.com>
      Cc: Guenter Roeck <linux@roeck-us.net>
      Cc: linux-hwmon@vger.kernel.org
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NEduardo Valentin <eduval@amazon.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      6029e581
  5. 31 5月, 2019 5 次提交
  6. 17 5月, 2019 1 次提交
  7. 17 4月, 2019 1 次提交
  8. 27 2月, 2019 1 次提交
  9. 23 2月, 2019 1 次提交
  10. 13 2月, 2019 2 次提交
  11. 17 12月, 2018 5 次提交
  12. 27 11月, 2018 1 次提交
  13. 21 11月, 2018 1 次提交
    • D
      hwmon: (core) Fix double-free in __hwmon_device_register() · a63fffbd
      Dmitry Osipenko 提交于
      commit 74e3512731bd5c9673176425a76a7cc5efa8ddb6 upstream.
      
      Fix double-free that happens when thermal zone setup fails, see KASAN log
      below.
      
      ==================================================================
      BUG: KASAN: double-free or invalid-free in __hwmon_device_register+0x5dc/0xa7c
      
      CPU: 0 PID: 132 Comm: kworker/0:2 Tainted: G    B             4.19.0-rc8-next-20181016-00042-gb52cd80401e9-dirty #41
      Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
      Workqueue: events deferred_probe_work_func
      Backtrace:
      [<c0110540>] (dump_backtrace) from [<c0110944>] (show_stack+0x20/0x24)
      [<c0110924>] (show_stack) from [<c105cb08>] (dump_stack+0x9c/0xb0)
      [<c105ca6c>] (dump_stack) from [<c02fdaec>] (print_address_description+0x68/0x250)
      [<c02fda84>] (print_address_description) from [<c02fd4ac>] (kasan_report_invalid_free+0x68/0x88)
      [<c02fd444>] (kasan_report_invalid_free) from [<c02fc85c>] (__kasan_slab_free+0x1f4/0x200)
      [<c02fc668>] (__kasan_slab_free) from [<c02fd0c0>] (kasan_slab_free+0x14/0x18)
      [<c02fd0ac>] (kasan_slab_free) from [<c02f9c6c>] (kfree+0x90/0x294)
      [<c02f9bdc>] (kfree) from [<c0b41bbc>] (__hwmon_device_register+0x5dc/0xa7c)
      [<c0b415e0>] (__hwmon_device_register) from [<c0b421e8>] (hwmon_device_register_with_info+0xa0/0xa8)
      [<c0b42148>] (hwmon_device_register_with_info) from [<c0b42324>] (devm_hwmon_device_register_with_info+0x74/0xb4)
      [<c0b422b0>] (devm_hwmon_device_register_with_info) from [<c0b4481c>] (lm90_probe+0x414/0x578)
      [<c0b44408>] (lm90_probe) from [<c0aeeff4>] (i2c_device_probe+0x35c/0x384)
      [<c0aeec98>] (i2c_device_probe) from [<c08776cc>] (really_probe+0x290/0x3e4)
      [<c087743c>] (really_probe) from [<c0877a2c>] (driver_probe_device+0x80/0x1c4)
      [<c08779ac>] (driver_probe_device) from [<c0877da8>] (__device_attach_driver+0x104/0x11c)
      [<c0877ca4>] (__device_attach_driver) from [<c0874dd8>] (bus_for_each_drv+0xa4/0xc8)
      [<c0874d34>] (bus_for_each_drv) from [<c08773b0>] (__device_attach+0xf0/0x15c)
      [<c08772c0>] (__device_attach) from [<c0877e24>] (device_initial_probe+0x1c/0x20)
      [<c0877e08>] (device_initial_probe) from [<c08762f4>] (bus_probe_device+0xdc/0xec)
      [<c0876218>] (bus_probe_device) from [<c0876a08>] (deferred_probe_work_func+0xa8/0xd4)
      [<c0876960>] (deferred_probe_work_func) from [<c01527c4>] (process_one_work+0x3dc/0x96c)
      [<c01523e8>] (process_one_work) from [<c01541e0>] (worker_thread+0x4ec/0x8bc)
      [<c0153cf4>] (worker_thread) from [<c015b238>] (kthread+0x230/0x240)
      [<c015b008>] (kthread) from [<c01010bc>] (ret_from_fork+0x14/0x38)
      Exception stack(0xcf743fb0 to 0xcf743ff8)
      3fa0:                                     00000000 00000000 00000000 00000000
      3fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
      3fe0: 00000000 00000000 00000000 00000000 00000013 00000000
      
      Allocated by task 132:
       kasan_kmalloc.part.1+0x58/0xf4
       kasan_kmalloc+0x90/0xa4
       kmem_cache_alloc_trace+0x90/0x2a0
       __hwmon_device_register+0xbc/0xa7c
       hwmon_device_register_with_info+0xa0/0xa8
       devm_hwmon_device_register_with_info+0x74/0xb4
       lm90_probe+0x414/0x578
       i2c_device_probe+0x35c/0x384
       really_probe+0x290/0x3e4
       driver_probe_device+0x80/0x1c4
       __device_attach_driver+0x104/0x11c
       bus_for_each_drv+0xa4/0xc8
       __device_attach+0xf0/0x15c
       device_initial_probe+0x1c/0x20
       bus_probe_device+0xdc/0xec
       deferred_probe_work_func+0xa8/0xd4
       process_one_work+0x3dc/0x96c
       worker_thread+0x4ec/0x8bc
       kthread+0x230/0x240
       ret_from_fork+0x14/0x38
         (null)
      
      Freed by task 132:
       __kasan_slab_free+0x12c/0x200
       kasan_slab_free+0x14/0x18
       kfree+0x90/0x294
       hwmon_dev_release+0x1c/0x20
       device_release+0x4c/0xe8
       kobject_put+0xac/0x11c
       device_unregister+0x2c/0x30
       __hwmon_device_register+0xa58/0xa7c
       hwmon_device_register_with_info+0xa0/0xa8
       devm_hwmon_device_register_with_info+0x74/0xb4
       lm90_probe+0x414/0x578
       i2c_device_probe+0x35c/0x384
       really_probe+0x290/0x3e4
       driver_probe_device+0x80/0x1c4
       __device_attach_driver+0x104/0x11c
       bus_for_each_drv+0xa4/0xc8
       __device_attach+0xf0/0x15c
       device_initial_probe+0x1c/0x20
       bus_probe_device+0xdc/0xec
       deferred_probe_work_func+0xa8/0xd4
       process_one_work+0x3dc/0x96c
       worker_thread+0x4ec/0x8bc
       kthread+0x230/0x240
       ret_from_fork+0x14/0x38
         (null)
      
      Cc: <stable@vger.kernel.org> # v4.15+
      Fixes: 47c332de ("hwmon: Deal with errors from the thermal subsystem")
      Signed-off-by: NDmitry Osipenko <digetx@gmail.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a63fffbd
  14. 14 11月, 2018 2 次提交
    • T
      hwmon: (pwm-fan) Set fan speed to 0 on suspend · 5764ffc8
      Thierry Reding 提交于
      [ Upstream commit 95dcd64bc5a27080beaa344edfe5bdcca3d2e7dc ]
      
      Technically this is not required because disabling the PWM should be
      enough. However, when support for atomic operations was implemented in
      the PWM subsystem, only actual changes to the PWM channel are applied
      during pwm_config(), which means that during after resume from suspend
      the old settings won't be applied.
      
      One possible solution is for the PWM driver to implement its own PM
      operations such that settings from before suspend get applied on resume.
      This has the disadvantage of completely ignoring any particular ordering
      requirements that PWM user drivers might have, so it is best to leave it
      up to the user drivers to apply the settings that they want at the
      appropriate time.
      
      Another way to solve this would be to read back the current state of the
      PWM at the time of resume. That way, in case the configuration was lost
      during suspend, applying the old settings in PWM user drivers would
      actually get them applied because they differ from the current settings.
      However, not all PWM drivers support reading the hardware state, and not
      all hardware may support it.
      
      The best workaround at this point seems to be to let PWM user drivers
      tell the PWM subsystem that the PWM is turned off by, in addition to
      disabling it, also setting the duty cycle to 0. This causes the resume
      operation to apply a configuration that is different from the current
      configuration, resulting in the proper state from before suspend getting
      restored.
      Signed-off-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NSasha Levin <sashal@kernel.org>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5764ffc8
    • D
      hwmon: (pmbus) Fix page count auto-detection. · 43cba96d
      Dmitry Bazhenov 提交于
      commit e7c6a55606b5c46b449d76588968b4d8caae903f upstream.
      
      Devices with compatible="pmbus" field have zero initial page count,
      and pmbus_clear_faults() being called before the page count auto-
      detection does not actually clear faults because it depends on the
      page count. Non-cleared faults in its turn may fail the subsequent
      page count auto-detection.
      
      This patch fixes this problem by calling pmbus_clear_fault_page()
      for currently set page and calling pmbus_clear_faults() after the
      page count was detected.
      
      Cc: stable@vger.kernel.org
      Signed-off-by: NDmitry Bazhenov <bazhenov.dn@gmail.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      43cba96d
  15. 06 10月, 2018 1 次提交
    • K
      treewide: Replace more open-coded allocation size multiplications · 329e0989
      Kees Cook 提交于
      As done treewide earlier, this catches several more open-coded
      allocation size calculations that were added to the kernel during the
      merge window. This performs the following mechanical transformations
      using Coccinelle:
      
      	kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
      	kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
      	devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)
      Signed-off-by: NKees Cook <keescook@chromium.org>
      329e0989
  16. 17 9月, 2018 1 次提交
  17. 16 9月, 2018 1 次提交
  18. 15 9月, 2018 1 次提交
    • G
      hwmon: (nct6775) Fix virtual temperature sources for NCT6796D · 37196ba4
      Guenter Roeck 提交于
      The following kernel log message is reported for the nct6775 driver
      on ASUS WS X299 SAGE.
      
      nct6775: Found NCT6796D or compatible chip at 0x2e:0x290
      nct6775 nct6775.656: Invalid temperature source 11 at index 0,
      			source register 0x100, temp register 0x73
      nct6775 nct6775.656: Invalid temperature source 11 at index 2,
      			source register 0x300, temp register 0x77
      nct6775 nct6775.656: Invalid temperature source 11 at index 3,
      			source register 0x800, temp register 0x79
      nct6775 nct6775.656: Invalid temperature source 11 at index 4,
      			source register 0x900, temp register 0x7b
      
      A recent version of the datasheet lists temperature source 11 as reserved.
      However, an older version of the datasheet lists temperature sources 10
      and 11 as supported virtual temperature sources. Apparently the older
      version of the datasheet is correct, so list those temperature sources
      as supported.
      
      Virtual temperature sources are different than other temperature sources:
      Values are not read from a temperature sensor, but written either from
      BIOS or an embedded controller. As such, each virtual temperature has to
      be reported. Since there is now more than one temperature source, we have
      to keep virtual temperature sources in a chip-specific mask and can no
      longer rely on the assumption that there is only one virtual temperature
      source with a fixed index. This accounts for most of the complexity of this
      patch.
      Reported-by: NRobert Kern <ulteq@web.de>
      Cc: Robert Kern <ulteq@web.de>
      Fixes: 81820059 ("hwmon: (nct6775) Add support for NCT6796D")
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      37196ba4
  19. 08 9月, 2018 1 次提交
    • G
      hwmon: (nct6775) Fix access to fan pulse registers · c793279c
      Guenter Roeck 提交于
      Not all fans have a fan pulse register. This can result in reading
      beyond the end of REG_FAN_PULSES and FAN_PULSE_SHIFT arrays,
      and was reported by smatch as possible error.
      
      1672          for (i = 0; i < ARRAY_SIZE(data->rpm); i++) {
                                    ^^^^^^^^^^^^^^^^^^^^^^^^
      			      This is a 7 element array.
      ...
      1685                  data->fan_pulses[i] =
      1686                    (nct6775_read_value(data, data->REG_FAN_PULSES[i])
      1687                          >> data->FAN_PULSE_SHIFT[i]) & 0x03;
                                       ^^^^^^^^^^^^^^^^^^^^^^^^
      				 FAN_PULSE_SHIFT is either 5 or 6
      				 elements.
      
      To fix the problem, we have to ensure that all REG_FAN_PULSES and
      FAN_PULSE_SHIFT have the appropriate length, and that REG_FAN_PULSES
      is only read if the register actually exists.
      
      Fixes: 6c009501 ("hwmon: (nct6775) Add support for NCT6102D/6106D")
      Reported-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NGuenter Roeck <linux@roeck-us.net>
      c793279c
  20. 06 9月, 2018 2 次提交
  21. 27 8月, 2018 4 次提交
  22. 11 8月, 2018 2 次提交