1. 22 1月, 2021 1 次提交
  2. 09 1月, 2021 1 次提交
    • D
      regulator: core: avoid regulator_resolve_supply() race condition · eaa7995c
      David Collins 提交于
      The final step in regulator_register() is to call
      regulator_resolve_supply() for each registered regulator
      (including the one in the process of being registered).  The
      regulator_resolve_supply() function first checks if rdev->supply
      is NULL, then it performs various steps to try to find the supply.
      If successful, rdev->supply is set inside of set_supply().
      
      This procedure can encounter a race condition if two concurrent
      tasks call regulator_register() near to each other on separate CPUs
      and one of the regulators has rdev->supply_name specified.  There
      is currently nothing guaranteeing atomicity between the rdev->supply
      check and set steps.  Thus, both tasks can observe rdev->supply==NULL
      in their regulator_resolve_supply() calls.  This then results in
      both creating a struct regulator for the supply.  One ends up
      actually stored in rdev->supply and the other is lost (though still
      present in the supply's consumer_list).
      
      Here is a kernel log snippet showing the issue:
      
      [   12.421768] gpu_cc_gx_gdsc: supplied by pm8350_s5_level
      [   12.425854] gpu_cc_gx_gdsc: supplied by pm8350_s5_level
      [   12.429064] debugfs: Directory 'regulator.4-SUPPLY' with parent
                     '17a00000.rsc:rpmh-regulator-gfxlvl-pm8350_s5_level'
                     already present!
      
      Avoid this race condition by holding the rdev->mutex lock inside
      of regulator_resolve_supply() while checking and setting
      rdev->supply.
      Signed-off-by: NDavid Collins <collinsd@codeaurora.org>
      Link: https://lore.kernel.org/r/1610068562-4410-1-git-send-email-collinsd@codeaurora.orgSigned-off-by: NMark Brown <broonie@kernel.org>
      eaa7995c
  3. 26 11月, 2020 1 次提交
  4. 14 11月, 2020 3 次提交
  5. 13 11月, 2020 3 次提交
  6. 11 11月, 2020 1 次提交
  7. 03 11月, 2020 1 次提交
  8. 29 10月, 2020 1 次提交
  9. 05 10月, 2020 1 次提交
  10. 02 10月, 2020 1 次提交
    • A
      regulator: core: Enlarge max OF property name length to 64 chars · e9bb4a06
      AngeloGioacchino Del Regno 提交于
      Some regulator drivers may be defining very long names: this is the
      case with the qcom_smd and qcom_spmi regulators, where we need to
      parse the regulator parents from DT.
      
      For clarity, this is an example:
      { "l13a", QCOM_SMD_RPM_LDOA, 13, &pm660_ht_lvpldo,
        "vdd_l8_l9_l10_l11_l12_l13_l14" },
      pm660-regulators {
      	...
      	vdd_l8_l9_l10_l11_l12_l13_l14-supply = <&vreg_s4a_2p04>
      	...
      };
      Now, with a 32 characters limit, the function is trying to parse,
      exactly, "vdd_l8_l9_l10_l11_l12_l13_l14-s" (32 chars) instead of
      the right one, which is 37 chars long in this specific case.
      
      ... And this is not only the case with PM660/PM660L, but also with
      PMA8084, PM8916, PM8950 and others that are not implemented yet.
      
      The length of 64 chars was chosen based on the longest parsed property
      name that I could find, which is in PM8916, and would be 53 characters
      long.
      At that point, rounding that to 64 looked like being the best idea.
      Signed-off-by: NAngeloGioacchino Del Regno <kholk11@gmail.com>
      Link: https://lore.kernel.org/r/20200926125549.13191-2-kholk11@gmail.comSigned-off-by: NMark Brown <broonie@kernel.org>
      e9bb4a06
  11. 29 9月, 2020 3 次提交
  12. 22 9月, 2020 2 次提交
  13. 08 9月, 2020 1 次提交
  14. 01 9月, 2020 1 次提交
  15. 24 8月, 2020 1 次提交
  16. 19 8月, 2020 2 次提交
  17. 17 8月, 2020 7 次提交
  18. 24 7月, 2020 1 次提交
    • V
      regulator: fix memory leak on error path of regulator_register() · 9177514c
      Vladimir Zapolskiy 提交于
      The change corrects registration and deregistration on error path
      of a regulator, the problem was manifested by a reported memory
      leak on deferred probe:
      
          as3722-regulator as3722-regulator: regulator 13 register failed -517
      
          # cat /sys/kernel/debug/kmemleak
          unreferenced object 0xecc43740 (size 64):
            comm "swapper/0", pid 1, jiffies 4294937640 (age 712.880s)
            hex dump (first 32 bytes):
              72 65 67 75 6c 61 74 6f 72 2e 32 34 00 5a 5a 5a  regulator.24.ZZZ
              5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a 5a  ZZZZZZZZZZZZZZZZ
            backtrace:
              [<0c4c3d1c>] __kmalloc_track_caller+0x15c/0x2c0
              [<40c0ad48>] kvasprintf+0x64/0xd4
              [<109abd29>] kvasprintf_const+0x70/0x84
              [<c4215946>] kobject_set_name_vargs+0x34/0xa8
              [<62282ea2>] dev_set_name+0x40/0x64
              [<a39b6757>] regulator_register+0x3a4/0x1344
              [<16a9543f>] devm_regulator_register+0x4c/0x84
              [<51a4c6a1>] as3722_regulator_probe+0x294/0x754
              ...
      
      The memory leak problem was introduced as a side ef another fix in
      regulator_register() error path, I believe that the proper fix is
      to decouple device_register() function into its two compounds and
      initialize a struct device before assigning any values to its fields
      and then using it before actual registration of a device happens.
      
      This lets to call put_device() safely after initialization, and, since
      now a release callback is called, kfree(rdev->constraints) shall be
      removed to exclude a double free condition.
      
      Fixes: a3cde953 ("regulator: core: fix regulator_register() error paths to properly release rdev")
      Signed-off-by: NVladimir Zapolskiy <vz@mleia.com>
      Cc: Wen Yang <wenyang@linux.alibaba.com>
      Link: https://lore.kernel.org/r/20200724005013.23278-1-vz@mleia.comSigned-off-by: NMark Brown <broonie@kernel.org>
      9177514c
  19. 20 7月, 2020 1 次提交
  20. 15 7月, 2020 1 次提交
  21. 30 5月, 2020 1 次提交
  22. 29 5月, 2020 1 次提交
  23. 30 4月, 2020 1 次提交
  24. 14 4月, 2020 1 次提交
  25. 14 3月, 2020 1 次提交
  26. 05 3月, 2020 1 次提交
    • J
      regulator: Use driver_deferred_probe_timeout for regulator_init_complete_work · dca0b449
      John Stultz 提交于
      The regulator_init_complete_work logic defers the cleanup for an
      arbitrary 30 seconds of time to allow modules loaded by userland
      to start.
      
      This arbitrary timeout is similar to the
      driver_deferred_probe_timeout value, and its been suggested we
      align these so users have a method to extend the timeouts as
      needed.
      
      So this patch changes the logic to use the
      driver_deferred_probe_timeout value for the delay value if it
      is set (using a delay of 0 if it is not).
      
      Cc: linux-pm@vger.kernel.org
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Linus Walleij <linus.walleij@linaro.org>
      Cc: Thierry Reding <treding@nvidia.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Liam Girdwood <lgirdwood@gmail.com>
      Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
      Cc: Saravana Kannan <saravanak@google.com>
      Cc: Todd Kjos <tkjos@google.com>
      Cc: Len Brown <len.brown@intel.com>
      Cc: Pavel Machek <pavel@ucw.cz>
      Cc: Ulf Hansson <ulf.hansson@linaro.org>
      Cc: Kevin Hilman <khilman@kernel.org>
      Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
      Cc: Rob Herring <robh@kernel.org>
      Acked-by: NMark Brown <broonie@kernel.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Link: https://lore.kernel.org/r/20200225050828.56458-7-john.stultz@linaro.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      dca0b449