Commit fbd741f0 authored by Pierre-Louis Bossart's avatar Pierre-Louis Bossart Committed by Mark Brown

ASoC: cs35l56: fix usages of device_get_named_child_node()

The documentation for device_get_named_child_node() mentions this
important point:

"
The caller is responsible for calling fwnode_handle_put() on the
returned fwnode pointer.
"

Add fwnode_handle_put() to avoid leaked references.
Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20240426152939.38471-1-pierre-louis.bossart@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent e8a6a5ad
...@@ -1360,6 +1360,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5 ...@@ -1360,6 +1360,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5
"spk-id-gpios", ACPI_TYPE_PACKAGE, &obj); "spk-id-gpios", ACPI_TYPE_PACKAGE, &obj);
if (ret) { if (ret) {
dev_dbg(cs35l56->base.dev, "Could not get spk-id-gpios package: %d\n", ret); dev_dbg(cs35l56->base.dev, "Could not get spk-id-gpios package: %d\n", ret);
fwnode_handle_put(af01_fwnode);
return -ENOENT; return -ENOENT;
} }
...@@ -1367,6 +1368,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5 ...@@ -1367,6 +1368,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5
if (obj->package.count != 4) { if (obj->package.count != 4) {
dev_warn(cs35l56->base.dev, "Unexpected spk-id element count %d\n", dev_warn(cs35l56->base.dev, "Unexpected spk-id element count %d\n",
obj->package.count); obj->package.count);
fwnode_handle_put(af01_fwnode);
return -ENOENT; return -ENOENT;
} }
...@@ -1381,6 +1383,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5 ...@@ -1381,6 +1383,7 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5
*/ */
ret = acpi_dev_add_driver_gpios(adev, cs35l56_af01_spkid_gpios_mapping); ret = acpi_dev_add_driver_gpios(adev, cs35l56_af01_spkid_gpios_mapping);
if (ret) { if (ret) {
fwnode_handle_put(af01_fwnode);
return dev_err_probe(cs35l56->base.dev, ret, return dev_err_probe(cs35l56->base.dev, ret,
"Failed to add gpio mapping to AF01\n"); "Failed to add gpio mapping to AF01\n");
} }
...@@ -1388,14 +1391,17 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5 ...@@ -1388,14 +1391,17 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5
ret = devm_add_action_or_reset(cs35l56->base.dev, ret = devm_add_action_or_reset(cs35l56->base.dev,
cs35l56_acpi_dev_release_driver_gpios, cs35l56_acpi_dev_release_driver_gpios,
adev); adev);
if (ret) if (ret) {
fwnode_handle_put(af01_fwnode);
return ret; return ret;
}
dev_dbg(cs35l56->base.dev, "Added spk-id-gpios mapping to AF01\n"); dev_dbg(cs35l56->base.dev, "Added spk-id-gpios mapping to AF01\n");
} }
desc = fwnode_gpiod_get_index(af01_fwnode, "spk-id", 0, GPIOD_IN, NULL); desc = fwnode_gpiod_get_index(af01_fwnode, "spk-id", 0, GPIOD_IN, NULL);
if (IS_ERR(desc)) { if (IS_ERR(desc)) {
fwnode_handle_put(af01_fwnode);
ret = PTR_ERR(desc); ret = PTR_ERR(desc);
return dev_err_probe(cs35l56->base.dev, ret, "Get GPIO from AF01 failed\n"); return dev_err_probe(cs35l56->base.dev, ret, "Get GPIO from AF01 failed\n");
} }
...@@ -1404,9 +1410,12 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5 ...@@ -1404,9 +1410,12 @@ static int cs35l56_try_get_broken_sdca_spkid_gpio(struct cs35l56_private *cs35l5
gpiod_put(desc); gpiod_put(desc);
if (ret < 0) { if (ret < 0) {
fwnode_handle_put(af01_fwnode);
dev_err_probe(cs35l56->base.dev, ret, "Error reading spk-id GPIO\n"); dev_err_probe(cs35l56->base.dev, ret, "Error reading spk-id GPIO\n");
return ret; return ret;
} }
fwnode_handle_put(af01_fwnode);
dev_info(cs35l56->base.dev, "Got spk-id from AF01\n"); dev_info(cs35l56->base.dev, "Got spk-id from AF01\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment