max77779_fg: plug memleak: case 2.2.2: for_each_child_of_node() (v6.12 prep)

Case 2.2.2 from below bug:

    If returning or breaking early from within
    for_each_child_of_node(), a reference to the current device_node
    remains and needs to be dropped, either right away, or later if
    used past that loop to avoid a memleak.

This driver uses for_each_child_of_node() to find the battery child
node. While for_each_child_of_node() free's each node using
of_node_put() during loop iteration and normal loop exit, drivers have
to do that explicitly if they exit the loop early, as is the case here
(in max77779_fg_find_batt_node()), to avoid a memory leak.

The battery child node needs to remain while this driver is active, so
it's correct to keep the reference past max77779_fg_find_batt_node(),
but it does need to be free'd during driver unload to avoid a memleak.

Add the missing of_node_put() during driver cleanup.

Test: TH
Bug: 370679843
Change-Id: I51298451cb5ce64a75753fbc44fc663c63944b98
Signed-off-by: AndrĂ© Draszik <[email protected]>
Signed-off-by: Will McVicker <[email protected]>
1 file changed
tree: 980110f284fc08acd03a489a700a5c9ed4de9849
  1. Documentation/
  2. misc/
  3. .checkpatch.conf
  4. BUILD.bazel
  5. gbms_power_supply.h
  6. gbms_storage.c
  7. gbms_storage.h
  8. google_battery.c
  9. google_bms.c
  10. google_bms.h
  11. google_ccd.c
  12. google_charger.c
  13. google_cpm.c
  14. google_dc_pps.c
  15. google_dc_pps.h
  16. google_dock.c
  17. google_dual_batt_gauge.c
  18. google_eeprom.c
  19. google_eeprom_01.c
  20. google_psy.h
  21. google_ttf.c
  22. Kconfig
  23. ln8411_A1.h
  24. ln8411_charger.h
  25. ln8411_driver.c
  26. ln8411_gbms_pps.c
  27. ln8411_regs.h
  28. Makefile
  29. max1720x.h
  30. max1720x_battery.c
  31. max1720x_battery.h
  32. max1720x_outliers.c
  33. max20339.c
  34. max77729_charger.c
  35. max77729_pmic.c
  36. max77729_uic.c
  37. max77759.h
  38. max77759_A1_regs.h
  39. max77759_charger.c
  40. max77759_charger.h
  41. max77759_maxq.c
  42. max77759_maxq.h
  43. max77759_regs.h
  44. max77759_usecase.c
  45. max77759_usecase.h
  46. max77759_v0p65_121919_regs.h
  47. max77779.h
  48. max77779_0227_v2.h
  49. max77779_charger.c
  50. max77779_charger.h
  51. max77779_charger_i2c.c
  52. max77779_fg.c
  53. max77779_fg.h
  54. max77779_fg_i2c.c
  55. max77779_fg_model.c
  56. max77779_fwupdate.c
  57. max77779_i2cm.c
  58. max77779_i2cm.h
  59. max77779_i2cm_i2c.c
  60. max77779_pmic.c
  61. max77779_pmic.h
  62. max77779_pmic_i2c.c
  63. max77779_pmic_irq.c
  64. max77779_pmic_pinctrl.c
  65. max77779_pmic_sgpio.c
  66. max77779_regs.h
  67. max77779_regs_1211.h
  68. max77779_sp.c
  69. max77779_sp.h
  70. max77779_sp_i2c.c
  71. max77779_usecase.c
  72. max77779_usecase.h
  73. max77779_v20240115_regs.h
  74. max77779_vimon.c
  75. max77779_vimon.h
  76. max77779_vimon_i2c.c
  77. max777x9_bcl.h
  78. max_m5.c
  79. max_m5.h
  80. max_m5_reg.h
  81. maxfg_common.c
  82. maxfg_common.h
  83. OWNERS
  84. p9221-dt-bindings.h
  85. p9221_charger.c
  86. p9221_charger.h
  87. p9221_chip.c
  88. pca9468_charger.c
  89. pca9468_charger.h
  90. pca9468_gbms_pps.c
  91. pca9468_regs.h
  92. pmic-voter-compat.c
  93. pmic-voter.h
  94. PREUPLOAD.cfg
  95. qmath.h
  96. rt9471_charger.c
  97. rt9471_charger.h