thermal/of: Fix potential uninitialized value access
authorPeng Fan <peng.fan@nxp.com>
Wed, 19 Jul 2023 01:16:36 +0000 (09:16 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 22 Aug 2023 19:22:02 +0000 (21:22 +0200)
commitf96801f0cfcefc0a16b146596577c53c75ee9773
treea3ee4724b389a0148678c4d6a94536eae0db544e
parentb616959a59eed098fe34aa156d96c37880feabc6
thermal/of: Fix potential uninitialized value access

If of_parse_phandle_with_args() called from __thermal_of_bind() or
__thermal_of_unbind() fails, cooling_spec.np will not be initialized,
so move the of_node_put() calls below the respective return value checks
to avoid dereferencing an uninitialized pointer.

Fixes: 3fd6d6e2b4e8 ("thermal/of: Rework the thermal device tree initialization")
Signed-off-by: Peng Fan <peng.fan@nxp.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/thermal/thermal_of.c