diff mbox series

ASoC: bcm: add missing call to of_node_put()

Message ID 1615187934-39505-1-git-send-email-yang.lee@linux.alibaba.com (mailing list archive)
State New, archived
Headers show
Series ASoC: bcm: add missing call to of_node_put() | expand

Commit Message

Yang Li March 8, 2021, 7:18 a.m. UTC
In one of the error paths of the for_each_child_of_node() loop,
add missing call to of_node_put().

Fix the following coccicheck warning:
./sound/soc/bcm/cygnus-ssp.c:1346:1-33: WARNING: Function
"for_each_available_child_of_node" should have of_node_put() before
return around line 1352.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
---
 sound/soc/bcm/cygnus-ssp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Scott Branden March 8, 2021, 8:10 p.m. UTC | #1
Hi Yang,

On 2021-03-07 11:18 p.m., Yang Li wrote:
> In one of the error paths of the for_each_child_of_node() loop,
> add missing call to of_node_put().
> 
> Fix the following coccicheck warning:
> ./sound/soc/bcm/cygnus-ssp.c:1346:1-33: WARNING: Function
> "for_each_available_child_of_node" should have of_node_put() before
> return around line 1352.
> 
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
> ---
>  sound/soc/bcm/cygnus-ssp.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c
> index 6e634b4..aa16a23 100644
> --- a/sound/soc/bcm/cygnus-ssp.c
> +++ b/sound/soc/bcm/cygnus-ssp.c
> @@ -1348,8 +1348,10 @@ static int cygnus_ssp_probe(struct platform_device *pdev)
>  					&cygnus_ssp_dai[active_port_count]);
>  
>  		/* negative is err, 0 is active and good, 1 is disabled */
> -		if (err < 0)
> +		if (err < 0) {
> +			of_node_put(child_node);
If such is needed in probe what about the other child_nodes in for_each_child_of_node loop that have already been parsed and succeeded.  Do they need additional cleanup as well?
>  			return err;
> +		}
>  		else if (!err) {
>  			dev_dbg(dev, "Activating DAI: %s\n",
>  				cygnus_ssp_dai[active_port_count].name);
>
diff mbox series

Patch

diff --git a/sound/soc/bcm/cygnus-ssp.c b/sound/soc/bcm/cygnus-ssp.c
index 6e634b4..aa16a23 100644
--- a/sound/soc/bcm/cygnus-ssp.c
+++ b/sound/soc/bcm/cygnus-ssp.c
@@ -1348,8 +1348,10 @@  static int cygnus_ssp_probe(struct platform_device *pdev)
 					&cygnus_ssp_dai[active_port_count]);
 
 		/* negative is err, 0 is active and good, 1 is disabled */
-		if (err < 0)
+		if (err < 0) {
+			of_node_put(child_node);
 			return err;
+		}
 		else if (!err) {
 			dev_dbg(dev, "Activating DAI: %s\n",
 				cygnus_ssp_dai[active_port_count].name);