ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt() [Linux 5.1]

ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt() [Linux 5.1]

This Linux kernel change "ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt()" is included in the Linux 5.1 release. This change is authored by Takashi Iwai <tiwai [at] suse.de> on Tue Feb 19 16:46:47 2019 +0100. The commit for this change in Linux stable tree is 2757970 (patch).

ASoC: fsl: Fix of-node refcount unbalance in fsl_ssi_probe_from_dt()

The node obtained from of_find_node_by_path() has to be unreferenced
after the use, but we forgot it for the root node.

Fixes: f0fba2ad1b6b ("ASoC: multi-component - ASoC Multi-Component Support")
Cc: Timur Tabi <[email protected]>
Cc: Nicolin Chen <[email protected]>
Cc: Xiubo Li <[email protected]>
Cc: Fabio Estevam <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
Acked-by: Nicolin Chen <[email protected]>
Signed-off-by: Mark Brown <[email protected]>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 sound/soc/fsl/fsl_ssi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
index 0a64822..09b2967 100644
--- a/sound/soc/fsl/fsl_ssi.c
+++ b/sound/soc/fsl/fsl_ssi.c
@@ -1439,8 +1439,10 @@ static int fsl_ssi_probe_from_dt(struct fsl_ssi *ssi)
     * different name to register the device.
     */
    if (!ssi->card_name[0] && of_get_property(np, "codec-handle", NULL)) {
-       sprop = of_get_property(of_find_node_by_path("/"),
-                   "compatible", NULL);
+       struct device_node *root = of_find_node_by_path("/");
+
+       sprop = of_get_property(root, "compatible", NULL);
+       of_node_put(root);
        /* Strip "fsl," in the compatible name if applicable */
        p = strrchr(sprop, ',');
        if (p)

Leave a Reply

Your email address will not be published. Required fields are marked *