Skip to contentSkip to conversation

mailbox: zynqmp-ipi-mailbox: Add of_node_put() before goto

PATCH In review Nishka Dasgupta 2 participants 6 messages Jul 9, 2019 – Aug 2, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mailbox: zynqmp-ipi-mailbox: Add of_node_put() before goto

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
index 86887c9a349a..bd80d4c10ec2 100644
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(dev, "failed to probe subdev.\n");
 			ret = -EINVAL;
+			of_node_put(nc);
 			goto free_mbox_dev;
 		}
 		mbox++;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 17 lines · Nishka Dasgupta

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
 drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +
 1 file changed, 1 insertion(+)
drivers/mailbox/zynqmp-ipi-mailbox.c +0 -0
index 86887c9a349a..bd80d4c10ec2 100644

drivers/mailbox/zynqmp-ipi-mailbox.c static int zynqmp_ipi_probe(struct platform_device *pdev) · line 667

Quoted 7 lines
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
 		if (ret) {
 			dev_err(dev, "failed to probe subdev.\n");
 			ret = -EINVAL;
+			of_node_put(nc);
 			goto free_mbox_dev;
 		}
 		mbox++;

Patch is good but when you are saying that this was found by Coccinelle then it should be added as script to kernel to detect it.

Thanks,
Michal

#2 lore raw
Quoted 12 lines · Michal Simek
Quoted 11 lines · Nishka Dasgupta

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
  drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +
  1 file changed, 1 insertion(+)
Quoted 16 lines

drivers/mailbox/zynqmp-ipi-mailbox.c static int zynqmp_ipi_probe(struct platform_device *pdev) · line 667

Quoted 13 lines
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
index 86887c9a349a..bd80d4c10ec2 100644
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct platform_device *pdev)
  		if (ret) {
  			dev_err(dev, "failed to probe subdev.\n");
  			ret = -EINVAL;
+			of_node_put(nc);
  			goto free_mbox_dev;
  		}
  		mbox++;

Patch is good but when you are saying that this was found by Coccinelle then it should be added as script to kernel to detect it.

This particular patch was suggested by a script I did not write myself; someone else wrote it and sent it to me. How should I proceed in this case?

Thanking you,
Nishka

Quoted 3 lines

Thanks,
Michal

#3 lore raw
Quoted 32 lines · Nishka Dasgupta
Quoted 22 lines · Michal Simek
Quoted 21 lines · Nishka Dasgupta

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
  drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +

  1 file changed, 1 insertion(+)
drivers/mailbox/zynqmp-ipi-mailbox.c +0 -0
index 86887c9a349a..bd80d4c10ec2 100644
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct
 platform_device *pdev)
           if (ret) {
               dev_err(dev, "failed to probe subdev.\n");
               ret = -EINVAL;
Quoted 8 lines
Quoted 5 lines
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
+            of_node_put(nc);
               goto free_mbox_dev;
           }

          mbox++;

Patch is good but when you are saying that this was found by Coccinelle then it should be added as script to kernel to detect it.

Quoted 2 lines

This particular patch was suggested by a script I did not write myself; someone else wrote it and sent it to me. How should I proceed in this case?

You can ask him to submit it to kernel.
Or you can take it, keep his authorship and send it to:

./scripts/get_maintainer.pl -f scripts/coccinelle/
Julia Lawall <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Gilles Muller <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Nicolas Palix <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Michal Marek <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
[email protected] (moderated list:COCCINELLE/Semantic Patches (SmPL)) [email protected] (open list)

Thanks,
Michal

#4 lore raw
Quoted 33 lines · Michal Simek
Quoted 32 lines · Nishka Dasgupta
Quoted 30 lines · Michal Simek
Quoted 24 lines · Nishka Dasgupta

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the goto.
Issue found with Coccinelle.

---
   drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +
   1 file changed, 1 insertion(+)
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
index 86887c9a349a..bd80d4c10ec2 100644
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct
 platform_device *pdev)
           if (ret) {
               dev_err(dev, "failed to probe subdev.\n");
               ret = -EINVAL;
+            of_node_put(nc);
               goto free_mbox_dev;
           }
Quoted 2 lines

          mbox++;

Patch is good but when you are saying that this was found by Coccinelle then it should be added as script to kernel to detect it.

Quoted 5 lines
Quoted 2 lines

This particular patch was suggested by a script I did not write myself; someone else wrote it and sent it to me. How should I proceed in this case?

You can ask him to submit it to kernel.
Or you can take it, keep his authorship and send it to:

I have asked her to submit this script, thank you. Will I need to resubmit this patch, however?

Regards,
Nishka

Quoted 15 lines

./scripts/get_maintainer.pl -f scripts/coccinelle/
Julia Lawall <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Gilles Muller <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Nicolas Palix <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
Michal Marek <[email protected]> (supporter:COCCINELLE/Semantic Patches (SmPL))
[email protected] (moderated list:COCCINELLE/Semantic Patches (SmPL)) [email protected] (open list)

Thanks,
Michal

#5 lore raw
Quoted 39 lines · Nishka Dasgupta
Quoted 38 lines · Michal Simek
Quoted 36 lines · Nishka Dasgupta
Quoted 23 lines · Michal Simek
Quoted 22 lines · Nishka Dasgupta

Each iteration of for_each_available_child_of_node puts the previous node, but in the case of a goto from the middle of the loop, there is no put, thus causing a memory leak. Hence add an of_node_put before the
goto.
Issue found with Coccinelle.

---
   drivers/mailbox/zynqmp-ipi-mailbox.c | 1 +

   1 file changed, 1 insertion(+)
drivers/mailbox/zynqmp-ipi-mailbox.c +0 -0
index 86887c9a349a..bd80d4c10ec2 100644
@@ -661,6 +661,7 @@ static int zynqmp_ipi_probe(struct
 platform_device *pdev)
            if (ret) {
                dev_err(dev, "failed to probe subdev.\n");
                ret = -EINVAL;
Quoted 8 lines
Quoted 5 lines
drivers/mailbox/zynqmp-ipi-mailbox.c +1 -0
+            of_node_put(nc);
                goto free_mbox_dev;
            }

           mbox++;

Patch is good but when you are saying that this was found by Coccinelle then it should be added as script to kernel to detect it.

This particular patch was suggested by a script I did not write myself; someone else wrote it and sent it to me. How should I proceed in this case?

Quoted 5 lines
Quoted 2 lines

You can ask him to submit it to kernel.
Or you can take it, keep his authorship and send it to:

I have asked her to submit this script, thank you. Will I need to resubmit this patch, however?

I will let Jassi to decide.

Thanks,
Michal