1. 02 12月, 2022 2 次提交
    • Y
      regulator: core: fix resource leak in regulator_register() · ba62319a
      Yang Yingliang 提交于
      I got some resource leak reports while doing fault injection test:
      
        OF: ERROR: memory leak, expected refcount 1 instead of 100,
        of_node_get()/of_node_put() unbalanced - destroy cset entry:
        attach overlay node /i2c/pmic@64/regulators/buck1
      
      unreferenced object 0xffff88810deea000 (size 512):
        comm "490-i2c-rt5190a", pid 253, jiffies 4294859840 (age 5061.046s)
        hex dump (first 32 bytes):
          00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
          ff ff ff ff ff ff ff ff a0 1e 00 a1 ff ff ff ff  ................
        backtrace:
          [<00000000d78541e2>] kmalloc_trace+0x21/0x110
          [<00000000b343d153>] device_private_init+0x32/0xd0
          [<00000000be1f0c70>] device_add+0xb2d/0x1030
          [<00000000e3e6344d>] regulator_register+0xaf2/0x12a0
          [<00000000e2f5e754>] devm_regulator_register+0x57/0xb0
          [<000000008b898197>] rt5190a_probe+0x52a/0x861 [rt5190a_regulator]
      
      unreferenced object 0xffff88810b617b80 (size 32):
        comm "490-i2c-rt5190a", pid 253, jiffies 4294859904 (age 5060.983s)
        hex dump (first 32 bytes):
          72 65 67 75 6c 61 74 6f 72 2e 32 38 36 38 2d 53  regulator.2868-S
          55 50 50 4c 59 00 ff ff 29 00 00 00 2b 00 00 00  UPPLY...)...+...
        backtrace:
          [<000000009da9280d>] __kmalloc_node_track_caller+0x44/0x1b0
          [<0000000025c6a4e5>] kstrdup+0x3a/0x70
          [<00000000790efb69>] create_regulator+0xc0/0x4e0
          [<0000000005ed203a>] regulator_resolve_supply+0x2d4/0x440
          [<0000000045796214>] regulator_register+0x10b3/0x12a0
          [<00000000e2f5e754>] devm_regulator_register+0x57/0xb0
          [<000000008b898197>] rt5190a_probe+0x52a/0x861 [rt5190a_regulator]
      
      After calling regulator_resolve_supply(), the 'rdev->supply' is set
      by set_supply(), after this set, in the error path, the resources
      need be released, so call regulator_put() to avoid the leaks.
      
      Fixes: aea6cb99 ("regulator: resolve supply after creating regulator")
      Fixes: 8a866d52 ("regulator: core: Resolve supply name earlier to prevent double-init")
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221202025111.496402-1-yangyingliang@huawei.comSigned-off-by: NMark Brown <broonie@kernel.org>
      ba62319a
    • Y
      regulator: core: fix module refcount leak in set_supply() · da46ee19
      Yang Yingliang 提交于
      If create_regulator() fails in set_supply(), the module refcount
      needs be put to keep refcount balanced.
      
      Fixes: e2c09ae7 ("regulator: core: Increase refcount for regulator supply's module")
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Link: https://lore.kernel.org/r/20221201122706.4055992-2-yangyingliang@huawei.comSigned-off-by: NMark Brown <broonie@kernel.org>
      da46ee19
  2. 01 12月, 2022 1 次提交
    • R
      regulator: core: fix use_count leakage when handling boot-on · 0591b14c
      Rui Zhang 提交于
      I found a use_count leakage towards supply regulator of rdev with
      boot-on option.
      
      ┌───────────────────┐           ┌───────────────────┐
      │  regulator_dev A  │           │  regulator_dev B  │
      │     (boot-on)     │           │     (boot-on)     │
      │    use_count=0    │──supply──│    use_count=1    │
      │                   │           │                   │
      └───────────────────┘           └───────────────────┘
      
      In case of rdev(A) configured with `regulator-boot-on', the use_count
      of supplying regulator(B) will increment inside
      regulator_enable(rdev->supply).
      
      Thus, B will acts like always-on, and further balanced
      regulator_enable/disable cannot actually disable it anymore.
      
      However, B was also configured with `regulator-boot-on', we wish it
      could be disabled afterwards.
      Signed-off-by: NRui Zhang <zr.zhang@vivo.com>
      Link: https://lore.kernel.org/r/20221201033806.2567812-1-zr.zhang@vivo.comSigned-off-by: NMark Brown <broonie@kernel.org>
      0591b14c
  3. 28 11月, 2022 2 次提交
  4. 26 11月, 2022 1 次提交
  5. 25 11月, 2022 1 次提交
    • J
      regulator: Drop obsolete dependencies on COMPILE_TEST · c4b02c92
      Jean Delvare 提交于
      Since commit 0166dc11 ("of: make CONFIG_OF user selectable"), it
      is possible to test-build any driver which depends on OF on any
      architecture by explicitly selecting OF. Therefore depending on
      COMPILE_TEST as an alternative is no longer needed.
      
      It is actually better to always build such drivers with OF enabled,
      so that the test builds are closer to how each driver will actually be
      built on its intended target. Building them without OF may not test
      much as the compiler will optimize out potentially large parts of the
      code. In the worst case, this could even pop false positive warnings.
      Dropping COMPILE_TEST here improves the quality of our testing and
      avoids wasting time on non-existent issues.
      
      As a minor optimization, this also lets us drop several occurrences of
      of_match_ptr(), __maybe_unused and some ifdef guarding, as we now know
      what all of this will resolve to, we might as well save cpp some work.
      Signed-off-by: NJean Delvare <jdelvare@suse.de>
      Cc: Liam Girdwood <lgirdwood@gmail.com>
      Cc: Mark Brown <broonie@kernel.org>
      Cc: Icenowy Zheng <icenowy@aosc.io>
      Link: https://lore.kernel.org/r/20221124144708.64371b98@endymion.delvareSigned-off-by: NMark Brown <broonie@kernel.org>
      c4b02c92
  6. 24 11月, 2022 9 次提交
  7. 23 11月, 2022 24 次提交