diff mbox series

[2/3] ASoC: fsl_utils: fix a leaked reference by adding missing of_node_put

Message ID 1551169071-11639-2-git-send-email-wen.yang99@zte.com.cn (mailing list archive)
State Not Applicable
Headers show
Series [1/3] ASoC: wcd9335: fix a leaked reference by adding missing of_node_put | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch warning next/apply_patch Patch failed to apply
snowpatch_ozlabs/apply_patch fail Failed to apply to any branch

Commit Message

Wen Yang Feb. 26, 2019, 8:17 a.m. UTC
The call to of_parse_phandle returns a node pointer with refcount
incremented thus it must be explicitly decremented after the last
usage.

Detected by coccinelle with the following warnings:
./sound/soc/fsl/fsl_utils.c:74:2-8: ERROR: missing of_node_put; acquired a node pointer with refcount incremented on line 38, but without a corresponding     object release within this function.

Signed-off-by: Wen Yang <wen.yang99@zte.com.cn>
Cc: Timur Tabi <timur@kernel.org>
Cc: Nicolin Chen <nicoleotsuka@gmail.com>
Cc: Xiubo Li <Xiubo.Lee@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: Liam Girdwood <lgirdwood@gmail.com>
Cc: Mark Brown <broonie@kernel.org>
Cc: Jaroslav Kysela <perex@perex.cz>
Cc: Takashi Iwai <tiwai@suse.com>
Cc: alsa-devel@alsa-project.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-kernel@vger.kernel.org
---
 sound/soc/fsl/fsl_utils.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Markus Elfring April 5, 2019, 12:30 p.m. UTC | #1
> @@ -71,6 +71,7 @@  int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
>  	iprop = of_get_property(dma_np, "cell-index", NULL);
>  	if (!iprop) {
>  		of_node_put(dma_np);
> +		of_node_put(dma_channel_np);
>  		return -EINVAL;
>  	}
>  	*dma_id = be32_to_cpup(iprop);

How do you think about to adjust the exception handling in this function
implementation a bit more according to the Linux coding style?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/sound/soc/fsl/fsl_utils.c?id=c705247136a523488eac806bd357c3e5d79a7acd#n16

Regards,
Markus
diff mbox series

Patch

diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c
index 9981668..040d06b 100644
--- a/sound/soc/fsl/fsl_utils.c
+++ b/sound/soc/fsl/fsl_utils.c
@@ -71,6 +71,7 @@  int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
 	iprop = of_get_property(dma_np, "cell-index", NULL);
 	if (!iprop) {
 		of_node_put(dma_np);
+		of_node_put(dma_channel_np);
 		return -EINVAL;
 	}
 	*dma_id = be32_to_cpup(iprop);