Thread (3 messages) 3 messages, 2 authors, 2024-09-18

Re: [PATCH] clk: at91: pmc: Use common error handling code in pmc_register_ops()

From: Markus Elfring <hidden>
Date: 2024-09-18 14:32:45
Also in: kernel-janitors, linux-clk, lkml

quoted
Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.
Bad track record and no real benefit from the patch:
NACK, sorry.
quoted
+++ b/drivers/clk/at91/pmc.c
@@ -162,20 +162,18 @@ static int __init pmc_register_ops(void)
         if (!np)
                 return -ENODEV;

-       if (!of_device_is_available(np)) {
-               of_node_put(np);
-               return -ENODEV;
-       }
+       if (!of_device_is_available(np))
+               goto put_node;
+
         of_node_put(np);

         np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-securam");
         if (!np)
                 return -ENODEV;

-       if (!of_device_is_available(np)) {
-               of_node_put(np);
-               return -ENODEV;
-       }
+       if (!of_device_is_available(np))
+               goto put_node;
+
         of_node_put(np);

         at91_pmc_backup_suspend = of_iomap(np, 0);
@@ -187,6 +185,10 @@ static int __init pmc_register_ops(void)
         register_syscore_ops(&pmc_syscore_ops);

         return 0;
+
+put_node:
+       of_node_put(np);
+       return -ENODEV;
  }
…

* Do you really disagree to advice from related information sources?
  https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources?

* How do you think about to increase the application of scope-based resource management?


Regards,
Markus
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help